From b195f57a6ad36f795c9a03e525357e5df246f26f Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Tue, 29 Sep 2015 08:08:08 -0400 Subject: Fixed extra entity, added mouse square, added quests class --- src/entities.cpp | 2 ++ src/main.cpp | 8 ++++++-- src/ui.cpp | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/entities.cpp b/src/entities.cpp index a7737b3..1058b1b 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -84,12 +84,14 @@ 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;ispawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village } + entity.pop_back(); return entity.size(); } } diff --git a/src/main.cpp b/src/main.cpp index 2dc5112..5c4fb77 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -128,7 +128,7 @@ int main(int argc, char *argv[]){ } player->loc.y+=player->vel.y*deltaTime; - player->loc.x+=player->vel.x*deltaTime; + player->loc.x+=(player->vel.x*player->speed)*deltaTime; render(); } @@ -188,6 +188,11 @@ void render(){ /************************** **** CLOSE THE LOOP **** **************************/ + int mx = ui::mouse.x, my=ui::mouse.y; + my = 720 - my; + mx -= (SCREEN_WIDTH/2); + glRectf(mx + player->loc.x, my, mx + player->loc.x + HLINE * 1, my + HLINE * 1); + 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 @@ -199,7 +204,6 @@ void logic(){ for(int i=0;i<=entity.size();i++){ if(entity[i]->alive&&entity[i]->type == NPCT){ entity[i]->wander((rand()%120 + 30), &entity[i]->vel); - //std::cout<<"works"<goWorldBack(player); // Go back a layer if possible if(SDL_KEY==SDLK_k)currentWorld=currentWorld->goWorldFront(player); // Go forward a layer if possible if(SDL_KEY==SDLK_F3)debug^=true; + if(SDL_KEY==SDLK_LSHIFT)player->speed = 3; // TEMPORARY UNTIL MOUSE if(SDL_KEY==SDLK_t){ @@ -181,6 +182,8 @@ namespace ui { case SDL_KEYUP: if(SDL_KEY==SDLK_a)player->vel.x=0; // Stop the player if movement keys are released if(SDL_KEY==SDLK_d)player->vel.x=0; + if(SDL_KEY==SDLK_LSHIFT)player->speed = 1; + break; default: break; -- cgit v1.2.3