World(void);\r
World(const float width,World *l,World *r);\r
void draw(void);\r
- void detect(vec2 *v,const float width);\r
+ void detect(vec2 *v,vec2 *vel,const float width);\r
float getWidth(void);\r
void saveToFile(FILE *f,World *parent);\r
void loadFromFile(FILE *f,World *parent);\r
case SDL_KEYDOWN:
if(e.key.keysym.sym == SDLK_d) player.right = true;
if(e.key.keysym.sym == SDLK_a) player.left = true;
- if(e.key.keysym.sym == SDLK_SPACE) player.loc.y += .5;
+ if(e.key.keysym.sym == SDLK_SPACE){
+ player.loc.y += HLINE*1.2;
+ player.vel.y += .004;
+ }
if(e.key.keysym.sym == SDLK_i)
if(currentWorld->behind){
player.loc.x-=(currentWorld->getWidth()-currentWorld->behind->getWidth())/2; // Match player's location to new area
}\r
}\r
}\r
-void World::detect(vec2 *v,const float width){\r
+void World::detect(vec2 *v,vec2 *vel,const float width){\r
unsigned int i;\r
// hey\r
// oh hai\r
for(i=0;i<lineCount-10;i++){\r
if(v->y<line[i].start){\r
if(v->x>(HLINE*i)-1&&v->x<(HLINE*i)-1+HLINE){\r
- v->y=line[i].start;\r
+ if(v->y<line[i].start){vel->y=0;v->y=line[i].start+HLINE;}\r
return;\r
}else if(v->x+width>(HLINE*i)-1&&v->x+width<(HLINE*i)-1+HLINE){\r
- v->y=line[i].start;\r
+ if(v->y<line[i].start){vel->y=0;v->y=line[i].start+HLINE;}\r
return;\r
}\r
- }else if(v->y>line[i].start+HLINE/4){\r
- v->y-=HLINE/32;\r
+ }else if(v->y>line[i].start+HLINE){\r
+ vel->y-=.00000001;\r
}\r
}\r
}\r
}
player.loc.x += player.vel.x*deltaTime; //update the player's x based on
+ player.loc.y += player.vel.y*deltaTime;
+
+ npc.loc.y += npc.vel.y*deltaTime;
gw=currentWorld->getWidth();
if(player.loc.x+player.width>-1+gw){
std::cout<<"\r("<<player.loc.x<<","<<player.loc.y<<")";
- currentWorld->detect(&player.loc,player.width);
- currentWorld->detect(&npc.loc,npc.height);
+ currentWorld->detect(&player.loc,&player.vel,player.width);
+ currentWorld->detect(&npc.loc,&player.vel,npc.height);
tickCount++;
}