|
|
@ -76,7 +76,7 @@ class Object{ |
|
|
|
int disableFlag; |
|
|
|
int disableFlag; |
|
|
|
int enableFlag; |
|
|
|
int enableFlag; |
|
|
|
//animationSpd is how long to wait before switching frames.
|
|
|
|
//animationSpd is how long to wait before switching frames.
|
|
|
|
Object(int id,std::string name,vi2d pos,Animation*spr,vi2d scale={1,1},Pixel color=WHITE,int animationSpd=1) { |
|
|
|
Object(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1) { |
|
|
|
this->spr=spr; |
|
|
|
this->spr=spr; |
|
|
|
this->pos=pos; |
|
|
|
this->pos=pos; |
|
|
|
this->id=id; |
|
|
|
this->id=id; |
|
|
@ -183,7 +183,7 @@ public: |
|
|
|
void updateGame(){ |
|
|
|
void updateGame(){ |
|
|
|
frameCount++; |
|
|
|
frameCount++; |
|
|
|
for (auto&obj:OBJECTS) { |
|
|
|
for (auto&obj:OBJECTS) { |
|
|
|
if (obj->frameCount++>obj->animationSpd) { |
|
|
|
if (obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) { |
|
|
|
obj->frameCount=0; |
|
|
|
obj->frameCount=0; |
|
|
|
obj->frameIndex++; |
|
|
|
obj->frameIndex++; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,7 +504,7 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (enabled) { |
|
|
|
if (enabled) { |
|
|
|
Object*newObj = new Object(id,OBJ_INFO[id]->name,{x,y},OBJ_INFO[id]->spr); |
|
|
|
Object*newObj = new Object(id,OBJ_INFO[id]->name,{x,y},OBJ_INFO[id]->spr,OBJ_INFO[id]->scale,OBJ_INFO[id]->color,OBJ_INFO[id]->animationSpd); |
|
|
|
OBJECTS.push_back(newObj); |
|
|
|
OBJECTS.push_back(newObj); |
|
|
|
} |
|
|
|
} |
|
|
|
printf("Object %s Loaded.\n",OBJ_INFO[id]->name.c_str()); |
|
|
|
printf("Object %s Loaded.\n",OBJ_INFO[id]->name.c_str()); |
|
|
@ -617,21 +617,21 @@ public: |
|
|
|
return new Decal(new Sprite("assets/"+spriteName)); |
|
|
|
return new Decal(new Sprite("assets/"+spriteName)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetupAnimations() { |
|
|
|
Object*CreateObject(Reference ref,std::string name,vd2d pos,std::string spriteFileName,int sprWidth,vd2d scale={1,1},Pixel tint=WHITE,int enableFlag=Flag::NONE,int disableFlag=Flag::NONE,int animationDelay=0) { |
|
|
|
SPRITES[PLAYER] = CreateSprite("player.png"); |
|
|
|
ANIMATIONS[ref] = new Animation(SPRITES[ref]=CreateSprite("player.png"),32); |
|
|
|
ANIMATIONS[PLAYER] = new Animation(SPRITES[PLAYER],32); |
|
|
|
Object*newObj = new Object(ref,name,pos,ANIMATIONS[ref],scale,tint,animationDelay); |
|
|
|
SPRITES[TILESET1] = CreateSprite("terrainmap.png"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object*CreateObject(Reference ref,std::string name,vd2d pos,int enableFlag=Flag::NONE,int disableFlag=Flag::NONE) { |
|
|
|
|
|
|
|
Object*newObj = new Object(ref,name,pos,ANIMATIONS[ref]); |
|
|
|
|
|
|
|
newObj->disableFlag=disableFlag; |
|
|
|
newObj->disableFlag=disableFlag; |
|
|
|
newObj->enableFlag=enableFlag; |
|
|
|
newObj->enableFlag=enableFlag; |
|
|
|
return newObj; |
|
|
|
return newObj; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SetupAnimations() { |
|
|
|
|
|
|
|
SPRITES[TILESET1] = CreateSprite("terrainmap.png"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SetupObjectInfo() { |
|
|
|
void SetupObjectInfo() { |
|
|
|
OBJ_INFO[PLAYER]=CreateObject(PLAYER,"player",{0,0}); |
|
|
|
OBJ_INFO[PLAYER]=CreateObject(PLAYER,"player",{0,0},"player.png",32,{2,2},BLUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Collision(vd2d pos) { |
|
|
|
bool Collision(vd2d pos) { |
|
|
|