mirror of
https://github.com/luksamuk/engine-psx.git
synced 2025-04-28 13:28:02 +03:00
Add a helper flag for ceiling collision
This commit is contained in:
parent
cf3d608df0
commit
712c80c682
4 changed files with 15 additions and 5 deletions
|
@ -73,6 +73,7 @@ typedef struct {
|
||||||
int8_t anim_dir;
|
int8_t anim_dir;
|
||||||
uint8_t idle_timer;
|
uint8_t idle_timer;
|
||||||
uint8_t grnd;
|
uint8_t grnd;
|
||||||
|
uint8_t ceil;
|
||||||
uint8_t push;
|
uint8_t push;
|
||||||
uint32_t spinrev;
|
uint32_t spinrev;
|
||||||
uint8_t ctrllock;
|
uint8_t ctrllock;
|
||||||
|
|
|
@ -65,9 +65,11 @@ static void _bubble_update(ObjectState *state, ObjectTableEntry *, VECTOR *);
|
||||||
|
|
||||||
// Player hitbox information. Calculated once per frame.
|
// Player hitbox information. Calculated once per frame.
|
||||||
static int32_t player_vx, player_vy; // Top left corner of player hitbox
|
static int32_t player_vx, player_vy; // Top left corner of player hitbox
|
||||||
|
static uint8_t player_attacking;
|
||||||
|
|
||||||
|
// TODO: ADJUST ACCORDING TO CHARACTER
|
||||||
static int32_t player_width = 16;
|
static int32_t player_width = 16;
|
||||||
static int32_t player_height = HEIGHT_RADIUS_NORMAL << 1;
|
static int32_t player_height = HEIGHT_RADIUS_NORMAL << 1;
|
||||||
static uint8_t player_attacking;
|
|
||||||
|
|
||||||
int player_hitbox_shown;
|
int player_hitbox_shown;
|
||||||
|
|
||||||
|
|
11
src/player.c
11
src/player.c
|
@ -147,7 +147,7 @@ load_player(Player *player,
|
||||||
player->anim_frame = player->anim_timer = 0;
|
player->anim_frame = player->anim_timer = 0;
|
||||||
player->anim_dir = 1;
|
player->anim_dir = 1;
|
||||||
player->idle_timer = ANIM_IDLE_TIMER_MAX;
|
player->idle_timer = ANIM_IDLE_TIMER_MAX;
|
||||||
player->grnd = player->push = 0;
|
player->grnd = player->ceil = player->push = 0;
|
||||||
|
|
||||||
player->ev_grnd1 = (CollisionEvent){ 0 };
|
player->ev_grnd1 = (CollisionEvent){ 0 };
|
||||||
player->ev_grnd2 = (CollisionEvent){ 0 };
|
player->ev_grnd2 = (CollisionEvent){ 0 };
|
||||||
|
@ -701,7 +701,8 @@ _player_update_collision_tb(Player *player)
|
||||||
new_coord = player->ev_ceil2.coord;
|
new_coord = player->ev_ceil2.coord;
|
||||||
|
|
||||||
player->pos.vy = (new_coord + 32) << 12;
|
player->pos.vy = (new_coord + 32) << 12;
|
||||||
}
|
player->ceil = 1;
|
||||||
|
} else player->ceil = 0;
|
||||||
|
|
||||||
// Cancel drop dash if not holding jump
|
// Cancel drop dash if not holding jump
|
||||||
if(player->action == ACTION_DROPDASH
|
if(player->action == ACTION_DROPDASH
|
||||||
|
@ -709,6 +710,10 @@ _player_update_collision_tb(Player *player)
|
||||||
player_set_action(player, ACTION_JUMPING);
|
player_set_action(player, ACTION_JUMPING);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if(!player->ev_ceil1.collided && !player->ev_ceil2.collided) {
|
||||||
|
player->ceil = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!player->ev_grnd1.collided && !player->ev_grnd2.collided) {
|
if(!player->ev_grnd1.collided && !player->ev_grnd2.collided) {
|
||||||
player->grnd = 0;
|
player->grnd = 0;
|
||||||
player->gsmode = player->psmode = CDIR_FLOOR;
|
player->gsmode = player->psmode = CDIR_FLOOR;
|
||||||
|
@ -1343,7 +1348,7 @@ player_update(Player *player)
|
||||||
player->ev_grnd2.collided ? "G" : " ",
|
player->ev_grnd2.collided ? "G" : " ",
|
||||||
player->ev_left.collided ? "L" : " ",
|
player->ev_left.collided ? "L" : " ",
|
||||||
player->ev_right.collided ? "R" : " ");
|
player->ev_right.collided ? "R" : " ");
|
||||||
font_draw_sm(buffer, 8, 67);
|
font_draw_sm(buffer, 8, 74);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset sensors
|
// Reset sensors
|
||||||
|
|
|
@ -659,6 +659,7 @@ screen_level_draw(void *d)
|
||||||
"ANG %08x G.P %s %s %3d\n"
|
"ANG %08x G.P %s %s %3d\n"
|
||||||
"POS %08x %08x\n"
|
"POS %08x %08x\n"
|
||||||
"ACT %02u\n"
|
"ACT %02u\n"
|
||||||
|
"GRN CEI %01u %01u\n"
|
||||||
,
|
,
|
||||||
player.vel.vz,
|
player.vel.vz,
|
||||||
player.vel.vx, player.vel.vy,
|
player.vel.vx, player.vel.vy,
|
||||||
|
@ -683,7 +684,8 @@ screen_level_draw(void *d)
|
||||||
: " ",
|
: " ",
|
||||||
(int32_t)(((int32_t)player.angle * (int32_t)(360 << 12)) >> 24), // angle in deg
|
(int32_t)(((int32_t)player.angle * (int32_t)(360 << 12)) >> 24), // angle in deg
|
||||||
player.pos.vx, player.pos.vy,
|
player.pos.vx, player.pos.vy,
|
||||||
player.action
|
player.action,
|
||||||
|
player.grnd, player.ceil
|
||||||
);
|
);
|
||||||
font_draw_sm(buffer, 8, 12);
|
font_draw_sm(buffer, 8, 12);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue