]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
fixed entity lags
authorClyne Sullivan <tullivan99@gmail.com>
Tue, 29 Sep 2015 12:46:47 +0000 (08:46 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Tue, 29 Sep 2015 12:46:47 +0000 (08:46 -0400)
Changelog
src/entities.cpp
src/main.cpp
src/ui.cpp
src/world.cpp

index d878ae92f28e852a5c21d3008871d24f05b6bb06..4ac0ba4c9cd2b6139b7abb69ecb42ee3e293bec6 100644 (file)
--- a/Changelog
+++ b/Changelog
        - fixed NPC generation
        - added enumerators for entity types
        - improved NPC wandering
+
+9/29/2015:
+==========
+
+       - made world handling work with interpolation
+       - successfully ran game 200 entities
+       - improved debug screen
+
index 3560a2da85ddd465b0627213db6a7a4e67d9849d..b33f2260493e755e092a8e8b248270e83b3576b3 100644 (file)
@@ -84,7 +84,6 @@ unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure
                height = 16 * HLINE;
 
                int tempN = (getRand() % 5 + 1); //amount of villagers that will spawn
-               //int tempN=200;
                for(int i=0;i<tempN;i++){
                        entity.push_back(new NPC()); //create a new entity of NPC type
                        npc.push_back(NPC()); //create new NPC
index d36929a62e871e9b2915abb31f92e1795356604a..cb3c086fb075c672108007bc3be2e99d2bad71bf 100644 (file)
@@ -174,7 +174,8 @@ void render(){
                        debugDiv=0;
                        rndy = player->loc.y;
                }
-               ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d G:%d\nRes: %ux%u\nE: %d\nPOS: (x)%.2f\n     (y)%.2f",fps,d,player->ground,SCREEN_WIDTH,SCREEN_HEIGHT,entity.size(),player->loc.x,rndy);
+               ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d G:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n     (y)%+.2f",
+                                       fps,d,player->ground,SCREEN_WIDTH,SCREEN_HEIGHT,entity.size(),player->loc.x,rndy);
        }
 
        ui::draw();                                                     // Draw any UI elements if they need to be
@@ -191,6 +192,7 @@ void render(){
        int mx = ui::mouse.x, my=ui::mouse.y;
        my = 720 - my;
        mx -= (SCREEN_WIDTH/2);
+       glColor3ub(0,0,0);
        glRectf(mx + player->loc.x, my, mx + player->loc.x + HLINE * 1, my + HLINE * 1);
 
 
index c0588ceab687a3ae87911ba57d36831f536fc1ac..ab15c897c71f3e7a23f00133b5c7b7c64b907fd5 100644 (file)
@@ -78,6 +78,7 @@ namespace ui {
                h=ftf->glyph->bitmap.rows;
                glEnable(GL_TEXTURE_2D);
                glBindTexture(GL_TEXTURE_2D,ftex);
+               if(c=='-')y+=fontSize/3;
                glBegin(GL_QUADS);
                        glColor3ub(255,255,255);
                        glTexCoord2f(0,1);glVertex2f(x,y);
index 7d27e17033664273b5e21f5c2de5b0aa2006586a..1d56643871280b8b318a6e8db6a8ff144a5f5165 100644 (file)
@@ -101,12 +101,6 @@ LOOP2:                                                                                                     // Draw each world
                        cline[i].y-=(yoff-DRAW_Y_OFFSET); // Reset 'cline[i]'`s y to what it was
                }
        glEnd();
-       for(i=0;i<entity.size()+1;i++){
-               if(entity[i]->inWorld==this){
-                       entity[i]->draw();
-                       ui::putText(entity[i]->loc.x,entity[i]->loc.y,"%d",i);
-               }
-       }
        safeSetColor(255+shade*2,0+shade,0+shade);
        for(i=0;i<current->platform.size();i++){
                glRectf(current->platform[i].p1.x,current->platform[i].p1.y+yoff-DRAW_Y_OFFSET,
@@ -120,6 +114,12 @@ LOOP2:                                                                                                     // Draw each world
        }else{                                                  // Otherwise reset static values and return
                yoff=DRAW_Y_OFFSET;
                shade=0;
+               for(i=0;i<entity.size()+1;i++){
+                       if(entity[i]->inWorld==this){
+                               entity[i]->draw();
+                               ui::putText(entity[i]->loc.x,entity[i]->loc.y,"%d",i);
+                       }
+               }
        }
 }
 
@@ -162,8 +162,9 @@ void World::detect(Player *p){
        unsigned int i;
        singleDetect(p);
        for(i=0;i<entity.size()+1;i++){
-               if(entity[i]->inWorld==this)
+               if(entity[i]->inWorld==this){
                        singleDetect(entity[i]);
+               }
        }
 }