#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()
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
entity[entity.size()] = &npc[npc.size()-1]; //set the new entity to have the same traits as an NPC
entity[entity.size()-1]->spawn(loc.x + (float)(i - 5),100); //sets the position of the villager around the village
}
+ entity.pop_back();
return entity.size();
}
}
}
player->loc.y+=player->vel.y*deltaTime;
- player->loc.x+=player->vel.x*deltaTime;
+ player->loc.x+=(player->vel.x*player->speed)*deltaTime;
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
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;
}
}
}
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){
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;