mirror of https://gitlab.com/drummyfish/anarch.git
Fix monster movement
This commit is contained in:
parent
256cfb3cb5
commit
9c2cbe6d0e
36
game.h
36
game.h
|
@ -2332,8 +2332,7 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
|
||||||
SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]),
|
SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]),
|
||||||
currentHeight) / 2);
|
currentHeight) / 2);
|
||||||
|
|
||||||
if (add)
|
state = SFG_MONSTER_STATE_IDLE;
|
||||||
state = SFG_MONSTER_STATE_IDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t newPos[2];
|
int16_t newPos[2];
|
||||||
|
@ -2349,16 +2348,33 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RCL_Unit newHeight =
|
uint8_t movingDiagonally = (coordAdd[0] != 0) && (coordAdd[1] != 0);
|
||||||
SFG_floorCollisionHeightAt(newPos[0] / 4,newPos[1] / 4);
|
|
||||||
|
|
||||||
collision =
|
// when moving diagonally, we need to check extra tiles
|
||||||
RCL_abs(currentHeight - newHeight) > RCL_CAMERA_COLL_STEP_HEIGHT;
|
|
||||||
|
|
||||||
if (!collision)
|
for (uint8_t i = 0; i < (1 + movingDiagonally); ++i)
|
||||||
collision =
|
{
|
||||||
(SFG_ceilingHeightAt(newPos[0] / 4,newPos[1] / 4) - newHeight) <
|
newPos[0] = monster->coords[0] + (i != 1) * coordAdd[0];
|
||||||
SFG_MONSTER_COLLISION_HEIGHT;
|
|
||||||
|
RCL_Unit newHeight =
|
||||||
|
SFG_floorCollisionHeightAt(
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(newPos[0]),
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(newPos[1]));
|
||||||
|
|
||||||
|
collision =
|
||||||
|
RCL_abs(currentHeight - newHeight) > RCL_CAMERA_COLL_STEP_HEIGHT;
|
||||||
|
|
||||||
|
if (!collision)
|
||||||
|
collision = (SFG_ceilingHeightAt(
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(newPos[0]),
|
||||||
|
SFG_MONSTER_COORD_TO_SQUARES(newPos[1])) - newHeight) <
|
||||||
|
SFG_MONSTER_COLLISION_HEIGHT;
|
||||||
|
|
||||||
|
if (collision)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
newPos[0] = monster->coords[0] + coordAdd[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collision)
|
if (collision)
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
#define SFG_REVEAL_MAP 1
|
#define SFG_REVEAL_MAP 1
|
||||||
// #define SFG_INFINITE_AMMO 1
|
// #define SFG_INFINITE_AMMO 1
|
||||||
|
|
||||||
#define SFG_SCREEN_RESOLUTION_X 127
|
// #define SFG_SCREEN_RESOLUTION_X 127
|
||||||
#define SFG_SCREEN_RESOLUTION_Y 42
|
// #define SFG_SCREEN_RESOLUTION_Y 42
|
||||||
|
|
||||||
// #define SFG_SCREEN_RESOLUTION_X 80
|
// #define SFG_SCREEN_RESOLUTION_X 80
|
||||||
// #define SFG_SCREEN_RESOLUTION_Y 64
|
// #define SFG_SCREEN_RESOLUTION_Y 64
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
//#define SFG_SCREEN_RESOLUTION_X 127
|
|
||||||
//#define SFG_SCREEN_RESOLUTION_Y 42
|
|
||||||
#define SFG_SCREEN_RESOLUTION_X 127
|
#define SFG_SCREEN_RESOLUTION_X 127
|
||||||
#define SFG_SCREEN_RESOLUTION_Y 42
|
#define SFG_SCREEN_RESOLUTION_Y 42
|
||||||
#define SFG_DITHERED_SHADOW 1
|
#define SFG_DITHERED_SHADOW 1
|
||||||
|
|
Loading…
Reference in New Issue