diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-16 11:33:02 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-09-16 11:33:02 -0400 |
commit | d7efa99f03f9d0eb5d84ed42249f227f13471079 (patch) | |
tree | 1385c96106d7fbb64a6081529255bcc1d2d48664 /src/main.cpp | |
parent | ba4b5bd76ae9b1fa3e3c862d8672e35b02e1664c (diff) |
shitty bug fixes
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3ae4206..eab1201 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,7 +3,7 @@ #include <chrono> #define TICKS_PER_SEC 20 -#define MSEC_PER_TICK 500//(1000/TICKS_PER_SEC) +#define MSEC_PER_TICK (1000/TICKS_PER_SEC) SDL_Window *window = NULL; SDL_Surface *renderSurface = NULL; @@ -22,7 +22,6 @@ Entity *entnpc[32]; //The NPC base Player player; //The actual player object NPC npc[32]; Structures build; -UIClass ui; //Yep World *currentWorld;//u-huh World *spawn; @@ -32,10 +31,10 @@ void render(); unsigned int millis(void){ std::chrono::system_clock::time_point now=std::chrono::system_clock::now(); - return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count(); + return std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()).count(); } -int main(int argc,char **argv){ +int main(/*int argc,char **argv*/){ //runs start-up procedures if(!SDL_Init(SDL_INIT_VIDEO)){ atexit(SDL_Quit); @@ -77,7 +76,7 @@ int main(int argc,char **argv){ **** GAMELOOP **** **************************/ - ui.init("ttf/VCR_OSD_MONO_1.001.ttf"); + ui::init("ttf/VCR_OSD_MONO_1.001.ttf"); irand(time(NULL)); entPlay = &player; @@ -116,6 +115,7 @@ int main(int argc,char **argv){ npc[i].loc.x += npc[i].vel.x * deltaTime; } } + render(); if(prevTime + MSEC_PER_TICK >= millis()){ //the logic loop to run at a dedicated time @@ -170,15 +170,15 @@ void render(){ glRectf(build.loc.x, build.loc.y, build.loc.x + build.width, build.loc.y + build.height); ///BWAHHHHHHHHHHHH - ui.setFontSize(16); + ui::setFontSize(16); if(++div==20){ div=0; d=deltaTime; fps=(1000/d); } - ui.putText(-.98 + player.loc.x, .94, "FPS: %1.0f\nDT: %1.0f",fps); + ui::putText(-.98 + player.loc.x, .94, "FPS: %1.0f\nDT: %1.0f",fps,d); //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); + ui::putText(player.loc.x,player.loc.y-(HLINE*10),"(%+1.3f,%+1.3f)",player.loc.x,player.loc.y); /************************** **** CLOSE THE LOOP **** @@ -186,8 +186,8 @@ void render(){ //DRAW MOUSE HERE!!!!!W glColor3ub(255,0,0); - mx=(ui.mousex/(float)SCREEN_WIDTH)*2.0f-1.0f; - my=((SCREEN_HEIGHT-ui.mousey)/(float)SCREEN_HEIGHT)*2.0f-1.0f; + mx=(ui::mousex/(float)SCREEN_WIDTH)*2.0f-1.0f; + my=((SCREEN_HEIGHT-ui::mousey)/(float)SCREEN_HEIGHT)*2.0f-1.0f; if(player.loc.x-1>-1)mx+=player.loc.x; glRectf(mx,my,mx+HLINE*4,my+HLINE*4); @@ -197,7 +197,8 @@ void render(){ void logic(){ float gw; - ui.handleEvents(); // Handle events + + ui::handleEvents(); // Handle events if(player.right)player.vel.x=.00075; else if(player.left)player.vel.x=-.00075; @@ -221,13 +222,17 @@ void logic(){ player.loc.x=-1+HLINE; } } - + currentWorld->detect(&build.loc,&build.vel,build.width); - 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()%181 + 1), &npc[i].vel); + /*for(int i = 0; i < 32; i++){ + if(entnpc[i]->alive){ + currentWorld->detect(&entnpc[i]->loc,&entnpc[i]->vel,entnpc[i]->width); + std::cout<<(void *)entnpc[i]<<" "<<i<<" "<<entnpc<<" "<<eAmt(entnpc)<<std::endl; + entnpc[i]->wander(30, &entnpc[i]->vel); } - } + }*/ + ////////////////////// + std::cout<<"shit"; + tickCount++; } |