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

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

@ -167,11 +167,21 @@ class Object{
Move(move);
return true;
} 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) {
for (int i=0;i<wiggleRoom;i++) { //Search Up.
if (!Collision({originPos.x+move.x,originPos.y-i})) {
//There is potentially to move up-right here, so we will do so.
Move({0,-1});
originPos.y+=-1;
return true;
}
}
@ -198,7 +208,7 @@ class Object{
return true;
}
}
} else
}
if (move.y>0) {
for (int i=0;i<wiggleRoom;i++) { //Search Left.
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:{
if (PlayerCanMove()) {
bool moved=false;
vd2d movementComponents = {0,0};
if (UpHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,-1})) {
UpdatePlayerTrail({0,-1});
moved=true;
}
movementComponents.y-=1;
}
if (DownHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({0,1})) {
UpdatePlayerTrail({0,1});
moved=true;
}
movementComponents.y+=1;
}
if (LeftHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({-1,0})) {
UpdatePlayerTrail({-1,0});
moved=true;
}
movementComponents.x-=1;
}
if (RightHeld()) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove({1,0})) {
UpdatePlayerTrail({1,0});
movementComponents.x+=1;
}
if (movementComponents.mag()>0) {
if (PARTY_MEMBER_OBJ[0]->SmoothMove(movementComponents)) {
UpdatePlayerTrail(movementComponents);
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) {
DrawFancyStringDecal({8+WIDTH/4+4+i*8,12*counter+8+displayYOffset},std::wstring(1,moves[i]->grade));
} 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 {
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() {
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]});
printf("HP:%d Max HP:%d",PARTY_MEMBER_STATS[i]->HP,PARTY_MEMBER_STATS[i]->maxHP);
}
PARTY_MEMBER_STATS[PLAYER]->moveSet={
MOVELIST[BattleMoveName::HAILSTORM_A],

Loading…
Cancel
Save