Smooth movement with vectorized movement and single axis collision resolving

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 8470606926
commit 7f2339ce19
  1. BIN
      C++ProjectTemplate
  2. 2
      assets/maps/map0
  3. 2
      assets/maps/map0_5
  4. 38
      main.cpp

Binary file not shown.

@ -53,6 +53,7 @@ OBJECT224.000000;128.000000;8
OBJECT160.000000;128.000000;8 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
OBJECT453.000000;133.000000;0
OBJECT313.000000;151.000000;8 OBJECT313.000000;151.000000;8
OBJECT313.000000;131.000000;10 OBJECT313.000000;131.000000;10
OBJECT192.000000;160.000000;8 OBJECT192.000000;160.000000;8
@ -60,7 +61,6 @@ OBJECT160.000000;160.000000;8
OBJECT256.000000;160.000000;8 OBJECT256.000000;160.000000;8
OBJECT224.000000;160.000000;7 OBJECT224.000000;160.000000;7
OBJECT288.000000;160.000000;7 OBJECT288.000000;160.000000;7
OBJECT123.000000;163.000000;0
OBJECT313.000000;136.000000;11 OBJECT313.000000;136.000000;11
OBJECT313.000000;141.000000;12 OBJECT313.000000;141.000000;12
OBJECT288.000000;160.000000;9 OBJECT288.000000;160.000000;9

@ -2,7 +2,7 @@
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????93;393;3??93:3:3:3;3??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????0717?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????0717??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

@ -167,11 +167,21 @@ class Object{
Move(move); Move(move);
return true; return true;
} else } else
if (move.x!=0&&!Collision({originPos.x+move.x,originPos.y})) {
Move({move.x,0});
return true;
} else
if (move.y!=0&&!Collision({originPos.x,originPos.y+move.y})) {
Move({0,move.y});
return true;
}
else
if (move.x>0) { if (move.x>0) {
for (int i=0;i<wiggleRoom;i++) { //Search Up. for (int i=0;i<wiggleRoom;i++) { //Search Up.
if (!Collision({originPos.x+move.x,originPos.y-i})) { if (!Collision({originPos.x+move.x,originPos.y-i})) {
//There is potentially to move up-right here, so we will do so. //There is potentially to move up-right here, so we will do so.
Move({0,-1}); Move({0,-1});
originPos.y+=-1;
return true; return true;
} }
} }
@ -198,7 +208,7 @@ class Object{
return true; return true;
} }
} }
} else }
if (move.y>0) { if (move.y>0) {
for (int i=0;i<wiggleRoom;i++) { //Search Left. for (int i=0;i<wiggleRoom;i++) { //Search Left.
if (!Collision({originPos.x-i,originPos.y+move.y})) { if (!Collision({originPos.x-i,originPos.y+move.y})) {
@ -902,27 +912,22 @@ goes on a very long time, I hope you can understand this is only for testing pur
case GameState::GAME_WORLD:{ case GameState::GAME_WORLD:{
if (PlayerCanMove()) { if (PlayerCanMove()) {
bool moved=false; bool moved=false;
vd2d movementComponents = {0,0};
if (UpHeld()) { if (UpHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,-1})) { movementComponents.y-=1;
UpdatePlayerTrail({0,-1});
moved=true;
}
} }
if (DownHeld()) { if (DownHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,1})) { movementComponents.y+=1;
UpdatePlayerTrail({0,1});
moved=true;
}
} }
if (LeftHeld()) { if (LeftHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({-1,0})) { movementComponents.x-=1;
UpdatePlayerTrail({-1,0});
moved=true;
}
} }
if (RightHeld()) { if (RightHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({1,0})) { movementComponents.x+=1;
UpdatePlayerTrail({1,0}); }
if (movementComponents.mag()>0) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) {
UpdatePlayerTrail(movementComponents);
moved=true; moved=true;
} }
} }
@ -1487,7 +1492,7 @@ goes on a very long time, I hope you can understand this is only for testing pur
if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==i) { if (POWER_GRADE_CURSOR[-CURRENT_TURN-1]==i) {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade)); DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade));
} else { } else {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade),VERY_DARK_GREY); DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade),DARK_GREY);
} }
} else { } else {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade)); DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade));
@ -1863,7 +1868,6 @@ 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},4,{MOVELIST[BattleMoveName::TESTMOVE1]});
printf("HP:%d Max HP:%d",PARTY_MEMBER_STATS[i]->HP,PARTY_MEMBER_STATS[i]->maxHP);
} }
PARTY_MEMBER_STATS[PLAYER]->moveSet={ PARTY_MEMBER_STATS[PLAYER]->moveSet={
MOVELIST[BattleMoveName::HAILSTORM_A], MOVELIST[BattleMoveName::HAILSTORM_A],

Loading…
Cancel
Save