generated from sigonasr2/CPlusPlusProjectTemplate
Align battle encounters to grid
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5f37838fc1
commit
328d5480f7
Binary file not shown.
42
main.cpp
42
main.cpp
@ -108,6 +108,9 @@ class Object{
|
||||
Pixel collisionData = GAME->GetDrawTarget()->GetPixel((int)pos.x-cameraPos.x,(int)pos.y-cameraPos.y);
|
||||
return collisionData!=MAGENTA;
|
||||
}
|
||||
//A grid version of the constructor. used ONLY for battle setups.
|
||||
Object(int id,std::string name,int gridx,int gridy,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false)
|
||||
:Object(id,name,{gridx*32-(spr->width*0.5)*(scale.x-1),gridy*32-(spr->spr->sprite->height)*(scale.y-1)},spr,scale,color,animationSpd,temp) {}
|
||||
Object(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1,bool temp=false) {
|
||||
this->spr=spr;
|
||||
this->pos=pos;
|
||||
@ -2003,7 +2006,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
|
||||
void SetupObjectInfo() {
|
||||
CreateObjectInfo(PLAYER,"player",{0,0},"player.png",32,{1,1},WHITE);
|
||||
CreateObjectInfo(PLAYER,"player",{0,0},"player.png",32,{2,2},WHITE);
|
||||
CreateObjectInfo(NESS,"Ness",{0,0},"player.png",32,{1,1},YELLOW);
|
||||
CreateObjectInfo(PAULA,"Paula",{0,0},"player.png",32,{1,1},MAGENTA);
|
||||
CreateObjectInfo(JEFF,"Jeff",{0,0},"player.png",32,{1,1},DARK_GREEN);
|
||||
@ -2174,24 +2177,24 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
|
||||
void SetupEncounters() {
|
||||
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_1,{0,0},std::array<vd2d,4>{vd2d
|
||||
{+10,+24},{+30,+24},{+50,+24},{+70,+24}},
|
||||
{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
|
||||
std::vector<Entity*>{
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{+20,+48},ANIMATIONS["player.png"]),
|
||||
NPC1_4,"Test Obj",3,2,ANIMATIONS["player.png"]),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj 2",{+40,+64},ANIMATIONS["player.png"]),
|
||||
NPC1_4,"Test Obj 2",1,3,ANIMATIONS["player.png"]),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj 3",{+60,+24},ANIMATIONS["player.png"]),
|
||||
NPC1_4,"Test Obj 3",2,2,ANIMATIONS["player.png"]),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
@ -2199,24 +2202,24 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}),
|
||||
}));//ENCOUNTER_1
|
||||
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_2,{0,0},std::array<vd2d,4>{vd2d
|
||||
{10,24},{30,24},{50,24},{70,24}},
|
||||
{grid(1,1)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
|
||||
std::vector<Entity*>{
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{20,48},ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
NPC1_4,"Test Obj",1,4,ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj 2",{40,64},ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
NPC1_4,"Test Obj 2",1,2,ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj 3",{60,24},ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
NPC1_4,"Test Obj 3",2,1,ANIMATIONS["player.png"],{2,2},GREEN),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},5,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
@ -2224,10 +2227,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}),
|
||||
}));//ENCOUNTER_2
|
||||
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_3,{0,0},std::array<vd2d,4>{vd2d
|
||||
{10,24},{30,24},{50,24},{70,24}},
|
||||
{grid(1,1)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
|
||||
std::vector<Entity*>{
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{20,48},ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
NPC1_4,"Test Obj",1,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
@ -2235,24 +2238,24 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}),
|
||||
}));//ENCOUNTER_3
|
||||
ENCOUNTER_LIST.push_back(new Encounter(encounter::ENCOUNTER_4,{0,0},std::array<vd2d,4>{vd2d
|
||||
{10,24},{30,24},{50,24},{70,24}},
|
||||
{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}},
|
||||
std::vector<Entity*>{
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{170,48},ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
NPC1_4,"Test Obj",6,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{200,48},ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
NPC1_4,"Test Obj",7,2,ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
MOVELIST[BattleMoveName::TESTMOVE3],
|
||||
}),
|
||||
new Entity(new Object(
|
||||
NPC1_4,"Test Obj",{100,160},ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
NPC1_4,"Test Obj",3,5,ANIMATIONS["player.png"],{1,1},MAGENTA),
|
||||
ㅎ 70,ㅎ 70,ㅍ 10,ㅍ 10,아 14,std::array<int,4>{0,0,0,0},0,std::vector<Battle::Move*>{
|
||||
MOVELIST[BattleMoveName::TESTMOVE1],
|
||||
MOVELIST[BattleMoveName::TESTMOVE2],
|
||||
@ -2714,7 +2717,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
allDone=false;
|
||||
}
|
||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||
if (!MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i],BATTLE_ENCOUNTER->playerPos[i]+BATTLE_ENCOUNTER->pos,PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) {
|
||||
if (!MoveObjectTowardsPoint(PARTY_MEMBER_OBJ[i],
|
||||
{BATTLE_ENCOUNTER->playerPos[i].x+BATTLE_ENCOUNTER->pos.x-PARTY_MEMBER_OBJ[i]->spr->width*0.5*(PARTY_MEMBER_OBJ[i]->GetScale().x-1),
|
||||
BATTLE_ENCOUNTER->playerPos[i].y+BATTLE_ENCOUNTER->pos.y-PARTY_MEMBER_OBJ[i]->spr->spr->sprite->height*1*(PARTY_MEMBER_OBJ[i]->GetScale().y-1)},
|
||||
PriorityDirection::BOTH,BATTLE_CAMERA_MOVESPD)) {
|
||||
allDone=false;
|
||||
}
|
||||
}
|
||||
@ -3154,6 +3160,10 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vi2d grid(int x, int y) {
|
||||
return {x*32,y*32};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user