diff options
author | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-14 21:20:01 -0400 |
---|---|---|
committer | Andy Belle-Isle <abelleisle@roadrunner.com> | 2015-09-14 21:20:09 -0400 |
commit | 45e83c53ee36d8999c00ebfc474d7ef3bb103c14 (patch) | |
tree | 8d801fa25cf2f72e144165054564329fa3d71c13 /src | |
parent | b04891e13dcb33ee8ea26470deae440d0c664420 (diff) |
Added mouse support, and debug
Added FPS display and deltaTime display
Diffstat (limited to 'src')
-rw-r--r-- | src/entities.cpp | 8 | ||||
-rw-r--r-- | src/main.cpp | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index e9e69ce..b418534 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -35,6 +35,10 @@ Player::Player(){ alive = true; } +void Player::interact(){ + +} + NPC::NPC(){ width = HLINE * 8; height = HLINE * 18; @@ -45,6 +49,10 @@ NPC::NPC(){ canMove = true; } +void NPC::interact(){ + +} + Structures::Structures(){ type = -1; speed = 0; diff --git a/src/main.cpp b/src/main.cpp index f3e95ee..905e4cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,7 @@ int main(int argc,char **argv){ glClearColor(.3,.5,.8,0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + SDL_ShowCursor(SDL_DISABLE); /************************** **** GAMELOOP **** @@ -113,7 +114,7 @@ int main(int argc,char **argv){ } player.loc.x += (player.vel.x * player.speed) * deltaTime; //update the player's x based on -// printf("%lf * %u\n",player.vel.y,deltaTime); + //printf("%lf * %u\n",player.vel.y,deltaTime); player.loc.y += player.vel.y * deltaTime; for(int i = 0; i < eAmt(entnpc); i++){ if(npc[i].alive == true){ @@ -122,6 +123,8 @@ int main(int argc,char **argv){ } } + SDL_GetMouseState((int*)(&ui.mousex), (int*)(&ui.mousey)); + ui.mousey = SCREEN_HEIGHT - ui.mousey; render(); } @@ -159,7 +162,6 @@ void render(){ /************************** **** RENDER STUFF HERE **** **************************/ - currentWorld->draw(); // layers dont scale x correctly... glColor3ub(120,30,30); //render the player glRectf(player.loc.x, player.loc.y, player.loc.x + player.width, player.loc.y + player.height); @@ -169,13 +171,20 @@ void render(){ glRectf(build.loc.x, build.loc.y, build.loc.x + build.width, build.loc.y + build.height); ///BWAHHHHHHHHHHHH + float d = deltaTime; + float fps = (1000 / d); + ui.setFontSize(16); + ui.putText(-.98 + player.loc.x, .94, "FPS: %1.0f",fps); + ui.putText(-.98 + player.loc.x, .88, "DT: %1.0f",d); ui.putText(player.loc.x,player.loc.y-(HLINE*10),"(%+1.3f,%+1.3f)",player.loc.x,player.loc.y); /************************** **** CLOSE THE LOOP **** **************************/ + //DRAW MOUSE HERE!!!!!W + glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer SDL_GL_SwapWindow(window); //give the stack to SDL to render it } @@ -188,6 +197,8 @@ void logic(){ else if(player.left)player.vel.x=-.00075; else player.vel.x = 0; + std::cout << deltaTime << std::endl; + currentWorld->detect(&player.loc,&player.vel,player.width); gw=currentWorld->getWidth(); if(player.loc.x+player.width>-1+gw){ @@ -211,7 +222,7 @@ void logic(){ for(int i = 0; i < eAmt(entnpc); i++){ if(npc[i].alive == true){ currentWorld->detect(&npc[i].loc,&npc[i].vel,npc[i].width); - entnpc[i]->wander((grand()%91 + 1), &npc[i].vel); + entnpc[i]->wander((grand()%181 + 1), &npc[i].vel); } } tickCount++; |