vec2 vel;
bool right,left, canMove;
bool alive;
- bool ground;
+ unsigned char ground;
unsigned int texture[];
};
class Structures : public Entity{
public:
+ World *inside;
Structures();
unsigned int spawn(int, float, float);
};
width = HLINE * 8;
height = HLINE * 12;
speed = 1;
- type = 0;
+ type = 1;
subtype = 0;
- alive = false;
+ alive = true;
canMove = true;
}
//int tempN = (getRand() % 5 + 1);
int tempN = 2;
for(int i=0;i<tempN;i++){
- entity.push_back(new Entity());
+ entity.push_back(new NPC());
npc.push_back(NPC());
std::cout<<"NPC:"<<npc.size()<<std::endl;
std::cout<<"Entity:"<<entity.size()<<std::endl;
entity[entity.size()] = &npc[npc.size()-1];
- entity[entity.size()]->alive=true;
- entity[entity.size()]->type = 1;
entity[entity.size()]->spawn(loc.x + (float)(i - 5) / 8,100);
}
return entity.size();
d=deltaTime;
debugDiv=0;
}
- ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d\nRes: %ux%u",fps,d,SCREEN_WIDTH,SCREEN_HEIGHT);
+ ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d G:%d\nRes: %ux%u",fps,d,player->ground,SCREEN_WIDTH,SCREEN_HEIGHT);
}
ui::draw(); // Draw any UI elements if they need to be
player->vel.x=.15;
currentWorld=currentWorld->goWorldRight(player);
}
+ if(SDL_KEY==SDLK_s && player->ground==2){
+ player->ground=false;
+ player->loc.y-=HLINE*1.5;
+ }
if(SDL_KEY==SDLK_SPACE){ // Jump
if(player->ground){
player->vel.y=.25;
}
glEnd();
for(i=0;i<entity.size()+1;i++){
- if(entity[i]->inWorld==current){
+ if(entity[i]->inWorld==this){
entity[i]->draw();
ui::putText(entity[i]->loc.x,entity[i]->loc.y,"%d",i);
}
unsigned int i;
if(e->alive){
i=(e->loc.x+e->width/2-x_start)/HLINE; // Calculate what line the player is currently on
- if(e->loc.y<=line[i].y){ // Snap the player to the top of that line if the player is inside it
- e->vel.y=0;
- e->ground=true;
- e->loc.y=line[i].y+HLINE/2;
- }else{ // If the player is above the ground do some gravity stuff
+ if(e->loc.y>line[i].y){ // Snap the player to the top of that line if the player is inside it
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->vel.y<0){
e->vel.y=0;
e->loc.y=platform[i].p2.y;
- e->ground=true;
+ e->ground=2;
+ return;
}
}
}
}
e->vel.y-=.01;
+ }else{
+ e->vel.y=0;
+ e->ground=true;
+ e->loc.y=line[i].y+HLINE/2;
}
if(e->loc.x<x_start){ // Keep the player inside world bounds (ui.cpp handles world jumping)
e->vel.x=0;