scaling, tinting, animation speeds for individual object info properties are now ocmbined

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent b8e480c8ca
commit e50fb90b29
  1. BIN
      C++ProjectTemplate
  2. 24
      main.cpp

Binary file not shown.

@ -76,7 +76,7 @@ class Object{
int disableFlag;
int enableFlag;
//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->pos=pos;
this->id=id;
@ -183,7 +183,7 @@ public:
void updateGame(){
frameCount++;
for (auto&obj:OBJECTS) {
if (obj->frameCount++>obj->animationSpd) {
if (obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) {
obj->frameCount=0;
obj->frameIndex++;
}
@ -504,7 +504,7 @@ public:
}
}
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);
}
printf("Object %s Loaded.\n",OBJ_INFO[id]->name.c_str());
@ -617,21 +617,21 @@ public:
return new Decal(new Sprite("assets/"+spriteName));
}
void SetupAnimations() {
SPRITES[PLAYER] = CreateSprite("player.png");
ANIMATIONS[PLAYER] = new Animation(SPRITES[PLAYER],32);
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]);
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) {
ANIMATIONS[ref] = new Animation(SPRITES[ref]=CreateSprite("player.png"),32);
Object*newObj = new Object(ref,name,pos,ANIMATIONS[ref],scale,tint,animationDelay);
newObj->disableFlag=disableFlag;
newObj->enableFlag=enableFlag;
return newObj;
}
void SetupAnimations() {
SPRITES[TILESET1] = CreateSprite("terrainmap.png");
}
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) {

Loading…
Cancel
Save