diff options
-rw-r--r-- | include/common.h | 2 | ||||
-rw-r--r-- | src/entities.cpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 8 | ||||
-rw-r--r-- | src/ui.cpp | 3 |
4 files changed, 11 insertions, 3 deletions
diff --git a/include/common.h b/include/common.h index 4f7ba48..2a35317 100644 --- a/include/common.h +++ b/include/common.h @@ -24,7 +24,7 @@ enum _TYPE { //these are the main types of entities #define SCREEN_HEIGHT 720 //#define FULLSCREEN -#define HLINE 3 //base unit of the world +#define HLINE 3 //base unit of the world #define initRand(s) srand(s) #define getRand() rand() diff --git a/src/entities.cpp b/src/entities.cpp index b33f226..3560a2d 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -84,6 +84,7 @@ 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 diff --git a/src/main.cpp b/src/main.cpp index ef2a7bc..d36929a 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"<<i<<std::endl; } } } @@ -165,6 +165,7 @@ namespace ui { if(SDL_KEY==SDLK_i)currentWorld=currentWorld->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; |