From 9137c25a3409a67ee04042e566f3c543d61d93d5 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 29 Sep 2015 08:46:47 -0400 Subject: fixed entity lags --- src/entities.cpp | 1 - src/main.cpp | 4 +++- src/ui.cpp | 1 + src/world.cpp | 15 ++++++++------- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/entities.cpp b/src/entities.cpp index 3560a2d..b33f226 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -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;iloc.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); diff --git a/src/ui.cpp b/src/ui.cpp index c0588ce..ab15c89 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -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); diff --git a/src/world.cpp b/src/world.cpp index 7d27e17..1d56643 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -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;iinWorld==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;iplatform.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;iinWorld==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;iinWorld==this) + if(entity[i]->inWorld==this){ singleDetect(entity[i]); + } } } -- cgit v1.2.3