generated from sigonasr2/CPlusPlusProjectTemplate
Detect collisions against terrain, allow passthrough through units.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e296a7b322
commit
998d695cd6
Binary file not shown.
@ -54,7 +54,6 @@ OBJECT160.000000;128.000000;8
|
|||||||
OBJECT192.000000;128.000000;8
|
OBJECT192.000000;128.000000;8
|
||||||
OBJECT288.000000;128.000000;8
|
OBJECT288.000000;128.000000;8
|
||||||
OBJECT313.000000;151.000000;8
|
OBJECT313.000000;151.000000;8
|
||||||
OBJECT35.000000;158.000000;0
|
|
||||||
OBJECT313.000000;131.000000;10
|
OBJECT313.000000;131.000000;10
|
||||||
OBJECT192.000000;160.000000;8
|
OBJECT192.000000;160.000000;8
|
||||||
OBJECT160.000000;160.000000;8
|
OBJECT160.000000;160.000000;8
|
||||||
@ -80,7 +79,7 @@ OBJECT256.000000;256.000000;8
|
|||||||
OBJECT224.000000;256.000000;8
|
OBJECT224.000000;256.000000;8
|
||||||
OBJECT192.000000;256.000000;8
|
OBJECT192.000000;256.000000;8
|
||||||
OBJECT160.000000;256.000000;8
|
OBJECT160.000000;256.000000;8
|
||||||
|
OBJECT208.000000;356.000000;0
|
||||||
ENCOUNTER64.000000;512.000000;90;2
|
ENCOUNTER64.000000;512.000000;90;2
|
||||||
ENCOUNTER64.000000;256.000000;50;1
|
|
||||||
ENCOUNTER192.000000;352.000000;100;1
|
ENCOUNTER192.000000;352.000000;100;1
|
||||||
ENCOUNTER480.000000;160.000000;100;3
|
ENCOUNTER480.000000;160.000000;100;3
|
@ -9,11 +9,11 @@
|
|||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????92??56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
??????????????????????9256??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????92??56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????56??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
77
main.cpp
77
main.cpp
@ -2017,7 +2017,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
|
|
||||||
void SetupPartyMemberStats() {
|
void SetupPartyMemberStats() {
|
||||||
for (int i=0;i<7;i++) {
|
for (int i=0;i<7;i++) {
|
||||||
PARTY_MEMBER_STATS[i]=new Entity(120,120,30,30,8,{0,0,0,0},4,{MOVELIST[BattleMoveName::TESTMOVE1]});
|
PARTY_MEMBER_STATS[i]=new Entity(120,120,30,30,8,{0,0,0,0},8,{MOVELIST[BattleMoveName::TESTMOVE1]});
|
||||||
}
|
}
|
||||||
PARTY_MEMBER_STATS[PLAYER]->moveSet={
|
PARTY_MEMBER_STATS[PLAYER]->moveSet={
|
||||||
MOVELIST[BattleMoveName::HAILSTORM_A],
|
MOVELIST[BattleMoveName::HAILSTORM_A],
|
||||||
@ -3323,33 +3323,54 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckGrid(int x,int y,vd2d pos,int lifetime) {
|
||||||
|
if (!MOVEMENT_GRID.count({x,y})) {
|
||||||
|
if (pos.x<0||pos.x>=WIDTH||pos.y<0||pos.y>=HEIGHT-64) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int xx=0;xx<32;xx++) {
|
||||||
|
for (int yy=0;yy<32;yy++) {
|
||||||
|
vi2d offset={xx,yy};
|
||||||
|
if (Collision(pos+offset)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool nonSolid=false; //Ran into a non-solid instance, which means we can't mark the tile, but we can continue moving through.
|
||||||
|
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
||||||
|
if (CURRENT_TURN!=-i-1&&pos==(vi2d)(PARTY_MEMBER_OBJ[i]->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||||
|
nonSolid=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!nonSolid) {
|
||||||
|
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
||||||
|
if (pos==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
||||||
|
nonSolid=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nonSolid) {
|
||||||
|
MOVEMENT_GRID[{x,y}]=pos;
|
||||||
|
}
|
||||||
|
if (lifetime>0) {
|
||||||
|
vi2d offsetLeft = {-32,0};
|
||||||
|
CheckGrid(x-1,y,pos+offsetLeft,lifetime-1);
|
||||||
|
vi2d offsetRight = {32,0};
|
||||||
|
CheckGrid(x+1,y,pos+offsetRight,lifetime-1);
|
||||||
|
vi2d offsetUp = {0,-32};
|
||||||
|
CheckGrid(x,y-1,pos+offsetUp,lifetime-1);
|
||||||
|
vi2d offsetDown = {0,32};
|
||||||
|
CheckGrid(x,y+1,pos+offsetDown,lifetime-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PopulateMovementGrid(vd2d pos,int range) {
|
void PopulateMovementGrid(vd2d pos,int range) {
|
||||||
vi2d gridCenter = (vi2d)pos/32*32;
|
vi2d gridCenter = (vi2d)pos/32*32;
|
||||||
MOVEMENT_GRID.clear();
|
MOVEMENT_GRID.clear();
|
||||||
for (int x=-range+1;x<range;x++) {
|
CheckGrid(0,0,gridCenter-cameraPos,range);
|
||||||
for (int y=-range+1;y<range;y++) {
|
|
||||||
int dist = abs(x)+abs(y);
|
|
||||||
if (dist<range) {
|
|
||||||
vi2d offset = {x,y};
|
|
||||||
MOVEMENT_GRID[{x,y}]=gridCenter-cameraPos+offset*32;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (std::map<std::pair<int,int>,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) {
|
|
||||||
vi2d offset = {it->first.first,it->first.second};
|
|
||||||
for (int i=0;i<PARTY_MEMBER_COUNT;i++) {
|
|
||||||
if (CURRENT_TURN!=-i-1&&MOVEMENT_GRID[it->first]==(vi2d)(BATTLE_ENCOUNTER->pos-PARTY_MEMBER_OBJ[i]->GetPosWithOrigin())/32*32) {
|
|
||||||
MOVEMENT_GRID[it->first]=NO_NEIGHBOR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i=0;i<BATTLE_ENCOUNTER->objs.size();i++) {
|
|
||||||
if (MOVEMENT_GRID[it->first]==(vi2d)(BATTLE_ENCOUNTER->objs[i]->obj->GetPosWithOrigin()-cameraPos)/32*32) {
|
|
||||||
MOVEMENT_GRID[it->first]=NO_NEIGHBOR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (std::map<std::pair<int,int>,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) {
|
for (std::map<std::pair<int,int>,vd2d>::const_iterator it = MOVEMENT_GRID.cbegin();it!=MOVEMENT_GRID.cend();++it) {
|
||||||
int gridX = it->first.first;
|
int gridX = it->first.first;
|
||||||
int gridY = it->first.second;
|
int gridY = it->first.second;
|
||||||
@ -3391,6 +3412,12 @@ goes on a very long time, I hope you can understand this is only for testing pur
|
|||||||
}
|
}
|
||||||
return memberID;
|
return memberID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Collision(vd2d pos) {
|
||||||
|
SetDrawTarget(layer::COLLISION);
|
||||||
|
Pixel collisionData = GAME->GetDrawTarget()->GetPixel((int)pos.x,(int)pos.y);
|
||||||
|
return collisionData!=MAGENTA;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user