2024-07-21 19:43:49 -03:00
|
|
|
#ifndef PLAYER_H
|
|
|
|
#define PLAYER_H
|
|
|
|
|
|
|
|
#include "chara.h"
|
|
|
|
#include <psxgte.h>
|
2024-08-04 18:36:59 -03:00
|
|
|
#include "level.h"
|
2024-08-16 01:11:53 -03:00
|
|
|
#include "collision.h"
|
2024-11-23 01:00:17 -03:00
|
|
|
#include "input.h"
|
2024-12-21 21:57:40 -03:00
|
|
|
#include "player_constants.h"
|
2024-07-21 19:43:49 -03:00
|
|
|
|
2024-12-21 21:57:40 -03:00
|
|
|
/* #define X_ACCEL 0x000c0 */
|
|
|
|
/* #define X_AIR_ACCEL 0x00180 */
|
|
|
|
/* #define X_FRICTION 0x000c0 */
|
|
|
|
/* #define X_DECEL 0x00800 */
|
|
|
|
/* #define X_TOP_SPD 0x06000 */
|
|
|
|
/* #define Y_GRAVITY 0x00380 */
|
|
|
|
/* #define Y_HURT_GRAVITY 0x00300 */
|
|
|
|
/* #define Y_MIN_JUMP 0x04000 */
|
|
|
|
/* #define Y_JUMP_STRENGTH 0x06800 */
|
|
|
|
/* #define X_MIN_ROLL_SPD 0x01000 */
|
|
|
|
/* #define X_MIN_UNCURL_SPD 0x00800 */
|
|
|
|
/* #define X_ROLL_FRICTION 0x00060 */
|
|
|
|
/* #define X_ROLL_DECEL 0x00200 */
|
|
|
|
/* #define X_SLOPE_MIN_SPD 0x000d0 */
|
|
|
|
/* #define X_SLOPE_NORMAL 0x00200 */
|
|
|
|
/* #define X_SLOPE_ROLLUP 0x00140 */
|
|
|
|
/* #define X_SLOPE_ROLLDOWN 0x00500 */
|
|
|
|
/* #define X_MAX_SPD 0x10000 */
|
|
|
|
/* #define X_MAX_SLIP_SPD 0x02800 */
|
|
|
|
/* #define X_DRPSPD 0x08000 */
|
|
|
|
/* #define X_DRPMAX 0x0c000 */
|
|
|
|
/* #define Y_HURT_FORCE 0x04000 */
|
|
|
|
/* #define X_HURT_FORCE 0x02000 */
|
2024-07-21 19:43:49 -03:00
|
|
|
|
2024-08-25 14:28:00 -03:00
|
|
|
// Constants for adjusting hitbox and sensors
|
2024-12-04 00:04:24 -03:00
|
|
|
#define WIDTH_RADIUS_NORMAL 9
|
2024-08-20 02:15:31 -03:00
|
|
|
#define HEIGHT_RADIUS_NORMAL 19
|
2025-01-07 12:42:31 -03:00
|
|
|
#define LEDGE_SENSOR_MAGNITUDE 26
|
2024-08-20 02:15:31 -03:00
|
|
|
#define WIDTH_RADIUS_ROLLING 7
|
|
|
|
#define HEIGHT_RADIUS_ROLLING 14
|
2024-12-04 00:04:24 -03:00
|
|
|
#define PUSH_RADIUS 10
|
2024-08-20 02:15:31 -03:00
|
|
|
|
2024-11-03 17:23:11 -03:00
|
|
|
#define PLAYER_HURT_IFRAMES 120
|
|
|
|
|
2024-08-19 01:05:12 -03:00
|
|
|
typedef enum {
|
|
|
|
ACTION_NONE,
|
|
|
|
ACTION_SKIDDING,
|
|
|
|
ACTION_LOOKUP,
|
2024-08-20 02:15:31 -03:00
|
|
|
ACTION_CROUCHDOWN,
|
2024-08-25 22:11:33 -03:00
|
|
|
ACTION_JUMPING,
|
2024-08-26 23:42:07 -03:00
|
|
|
ACTION_ROLLING,
|
2024-09-08 17:05:05 -03:00
|
|
|
ACTION_SPINDASH,
|
2024-11-03 01:46:09 -03:00
|
|
|
ACTION_DROPDASH,
|
|
|
|
ACTION_SPRING,
|
2024-11-03 17:23:11 -03:00
|
|
|
ACTION_HURT,
|
2024-08-19 01:05:12 -03:00
|
|
|
} PlayerAction;
|
|
|
|
|
2024-11-28 01:36:09 -03:00
|
|
|
// Alias to make things look less weird
|
|
|
|
typedef LinecastDirection CollMode;
|
|
|
|
|
2024-07-21 19:43:49 -03:00
|
|
|
typedef struct {
|
2024-12-21 21:57:40 -03:00
|
|
|
InputState input;
|
|
|
|
PlayerConstants *cnst;
|
|
|
|
Chara chara;
|
2024-07-21 19:43:49 -03:00
|
|
|
|
|
|
|
CharaAnim *cur_anim;
|
|
|
|
VECTOR pos;
|
2024-08-02 21:10:58 -03:00
|
|
|
VECTOR vel; // vel.vz = ground speed
|
2024-08-05 00:12:44 -03:00
|
|
|
int32_t angle;
|
2024-07-21 19:43:49 -03:00
|
|
|
uint8_t anim_frame;
|
|
|
|
uint8_t anim_timer;
|
2024-08-17 13:12:56 -03:00
|
|
|
uint8_t frame_duration;
|
2024-08-17 13:19:27 -03:00
|
|
|
uint8_t loopback_frame;
|
2024-07-21 19:43:49 -03:00
|
|
|
int8_t anim_dir;
|
|
|
|
uint8_t idle_timer;
|
|
|
|
uint8_t grnd;
|
2024-08-05 00:12:44 -03:00
|
|
|
uint8_t push;
|
2024-08-26 23:42:07 -03:00
|
|
|
uint32_t spinrev;
|
2024-08-27 02:01:33 -03:00
|
|
|
uint8_t ctrllock;
|
2024-11-03 01:46:09 -03:00
|
|
|
uint8_t airdirlock;
|
2024-09-08 17:05:05 -03:00
|
|
|
uint8_t framecount;
|
|
|
|
uint8_t holding_jump;
|
2024-11-03 17:23:11 -03:00
|
|
|
uint16_t iframes;
|
2024-11-12 19:34:17 -03:00
|
|
|
uint8_t shield;
|
2024-12-22 01:47:02 -03:00
|
|
|
int32_t speedshoes_frames;
|
2024-08-04 18:36:59 -03:00
|
|
|
|
2024-12-19 01:50:49 -03:00
|
|
|
// TODO: Change this to player value modes.
|
|
|
|
// For now we're only storing info on whether
|
|
|
|
// player is underwater
|
2024-12-21 01:15:11 -03:00
|
|
|
uint8_t underwater;
|
|
|
|
uint16_t remaining_air_frames;
|
2024-12-19 01:50:49 -03:00
|
|
|
|
2024-11-28 01:36:09 -03:00
|
|
|
// Collision modes
|
|
|
|
CollMode gsmode;
|
|
|
|
CollMode psmode;
|
|
|
|
|
2024-08-19 01:05:12 -03:00
|
|
|
PlayerAction action;
|
|
|
|
|
2025-01-07 11:27:45 -03:00
|
|
|
uint8_t col_ledge;
|
2024-08-04 18:36:59 -03:00
|
|
|
CollisionEvent ev_grnd1;
|
|
|
|
CollisionEvent ev_grnd2;
|
|
|
|
CollisionEvent ev_left;
|
|
|
|
CollisionEvent ev_right;
|
|
|
|
CollisionEvent ev_ceil1;
|
|
|
|
CollisionEvent ev_ceil2;
|
2024-10-11 22:12:58 -03:00
|
|
|
|
|
|
|
VECTOR startpos;
|
2025-01-07 23:58:52 -03:00
|
|
|
VECTOR respawnpos;
|
2024-07-21 19:43:49 -03:00
|
|
|
} Player;
|
|
|
|
|
|
|
|
void load_player(Player *player, const char *chara_filename, TIM_IMAGE *sprites);
|
|
|
|
void free_player(Player *player);
|
|
|
|
|
|
|
|
void player_set_animation(Player *player, const char *name);
|
|
|
|
void player_set_animation_precise(Player *player, const char *name);
|
|
|
|
void player_set_animation_direct(Player *player, uint32_t sum);
|
2024-08-17 13:12:56 -03:00
|
|
|
void player_set_frame_duration(Player *player, uint8_t duration);
|
2024-08-17 11:01:01 -03:00
|
|
|
uint32_t player_get_current_animation_hash(Player *player);
|
2024-07-21 19:43:49 -03:00
|
|
|
CharaAnim *player_get_animation(Player *player, uint32_t sum);
|
|
|
|
CharaAnim *player_get_animation_by_name(Player *player, const char *name);
|
|
|
|
|
|
|
|
void player_update(Player *player);
|
2024-08-02 21:10:58 -03:00
|
|
|
void player_draw(Player *player, VECTOR *screen_pos);
|
2024-07-21 19:43:49 -03:00
|
|
|
|
2024-11-12 19:34:17 -03:00
|
|
|
void player_do_damage(Player *player, int32_t hazard_x);
|
2024-11-03 17:23:11 -03:00
|
|
|
|
2024-07-21 19:43:49 -03:00
|
|
|
#endif
|