diff options
-rw-r--r-- | include/UIClass.h | 2 | ||||
-rw-r--r-- | include/entities.h | 3 | ||||
-rw-r--r-- | src/entities.cpp | 8 | ||||
-rw-r--r-- | src/main.cpp | 17 |
4 files changed, 27 insertions, 3 deletions
diff --git a/include/UIClass.h b/include/UIClass.h index 9aafbd3..62d3e7e 100644 --- a/include/UIClass.h +++ b/include/UIClass.h @@ -14,6 +14,8 @@ public: void putText(const float x,const float y,const char *s,...);
void putString(const float x,const float y,const char *s);
void handleEvents();
+
+ float mousex, mousey;
};
#endif // UICLASS_H
diff --git a/include/entities.h b/include/entities.h index 2ed97ee..7d5e356 100644 --- a/include/entities.h +++ b/include/entities.h @@ -19,6 +19,7 @@ public: void spawn(float, float); void draw(void); void wander(int, vec2*); + virtual void interact(){} private: int ticksToUse; }; @@ -26,11 +27,13 @@ private: class Player : public Entity{ public: Player(); + void interact(); }; class NPC : public Entity{ public: NPC(); + void interact(); }; extern Entity *entnpc[32]; //The NPC base 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++; |