#include <SDL2/SDL_opengl.h>
typedef struct { float x; float y; } vec2;
-enum _TYPE {STRUCTURET = -1, PLAYERT = 0, NPCT = 1}; //these are the main types of entities
+
+enum _TYPE { //these are the main types of entities
+ STRUCTURET = -1,
+ PLAYERT = 0,
+ NPCT = 1
+};
#include <entities.h>
template<typename T, size_t N> //this fuction returns the size of any array
int eAmt(T (&)[N]){return N;}
-//SDL VARIABLES
-extern SDL_Window *window;
-extern SDL_Surface *renderSurface;
-extern SDL_GLContext mainGLContext;
-
extern bool gameRunning;
+extern unsigned int deltaTime;
#endif // COMMON_H
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();
}
}
SDL_GLContext mainGLContext = NULL;
bool gameRunning = true;
-static unsigned int tickCount = 0,
- prevTime = 0,
- currentTime = 0,
- deltaTime = 0;
+unsigned int tickCount = 0,
+ prevTime = 0,
+ currentTime = 0,
+ deltaTime = 0;
World *currentWorld=NULL;
Player *player;
if(SDL_KEY==SDLK_w)currentWorld=currentWorld->goInsideStructure(player);
if(SDL_KEY==SDLK_SPACE){ // Jump
if(player->ground){
- player->vel.y=.25;
- //player->loc.y+=HL
+ player->vel.y=.5;
+ player->loc.y+=HLINE*2;
player->ground=false;
}
}
for(i=0;i<platform.size();i++){
if(((e->loc.x+e->width>platform[i].p1.x)&(e->loc.x+e->width<platform[i].p2.x))||
((e->loc.x<platform[i].p2.x)&(e->loc.x>platform[i].p1.x))){
- if(e->loc.y>platform[i].p2.y-HLINE&&e->loc.y<platform[i].p2.y){
+ if(e->loc.y>platform[i].p1.y&&e->loc.y<platform[i].p2.y){
if(e->vel.y<0){
e->vel.y=0;
e->loc.y=platform[i].p2.y;
}
}
}
- e->vel.y-=.01;
+ e->vel.y-=.001*deltaTime;
}else{
e->vel.y=0;
e->ground=true;