mirror of
https://github.com/luksamuk/engine-psx.git
synced 2025-04-28 13:28:02 +03:00
Introduce Knuckles' values
This commit is contained in:
parent
1dce63d4d3
commit
a36ebab06e
5 changed files with 127 additions and 18 deletions
|
@ -44,6 +44,15 @@ typedef enum {
|
||||||
// Alias to make things look less weird
|
// Alias to make things look less weird
|
||||||
typedef LinecastDirection CollMode;
|
typedef LinecastDirection CollMode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
PC_DEFAULT,
|
||||||
|
PC_UNDERWATER,
|
||||||
|
PC_SPEEDSHOES,
|
||||||
|
} PlayerConstantType;
|
||||||
|
|
||||||
|
// declared in player_constants.c
|
||||||
|
PlayerConstants *getconstants(PlayerCharacter, PlayerConstantType);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
InputState input;
|
InputState input;
|
||||||
PlayerConstants *cnst;
|
PlayerConstants *cnst;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
// Extern elements
|
// Extern elements
|
||||||
extern Player player;
|
extern Player player;
|
||||||
extern Camera camera;
|
extern Camera camera;
|
||||||
extern PlayerConstants CNST_SPEEDSHOES;
|
|
||||||
extern TileMap16 map16;
|
extern TileMap16 map16;
|
||||||
extern TileMap128 map128;
|
extern TileMap128 map128;
|
||||||
extern LevelData leveldata;
|
extern LevelData leveldata;
|
||||||
|
@ -617,7 +616,7 @@ _monitor_image_update(ObjectState *state, ObjectTableEntry *, VECTOR *)
|
||||||
case MONITOR_KIND_SPEEDSHOES:
|
case MONITOR_KIND_SPEEDSHOES:
|
||||||
// Start speed shoes count
|
// Start speed shoes count
|
||||||
player.speedshoes_frames = 1200; // 20 seconds
|
player.speedshoes_frames = 1200; // 20 seconds
|
||||||
player.cnst = &CNST_SPEEDSHOES;
|
player.cnst = getconstants(player.character, PC_SPEEDSHOES);
|
||||||
sound_bgm_play(BGM_SPEEDSHOES);
|
sound_bgm_play(BGM_SPEEDSHOES);
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
|
|
21
src/player.c
21
src/player.c
|
@ -10,10 +10,7 @@
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
#include "basic_font.h"
|
#include "basic_font.h"
|
||||||
|
#include "player_constants.h"
|
||||||
extern PlayerConstants CNST_DEFAULT;
|
|
||||||
extern PlayerConstants CNST_UNDERWATER;
|
|
||||||
extern PlayerConstants CNST_SPEEDSHOES;
|
|
||||||
|
|
||||||
#define TMP_ANIM_SPD 7
|
#define TMP_ANIM_SPD 7
|
||||||
#define ANIM_IDLE_TIMER_MAX 180
|
#define ANIM_IDLE_TIMER_MAX 180
|
||||||
|
@ -125,11 +122,12 @@ load_player(Player *player,
|
||||||
const char *chara_filename,
|
const char *chara_filename,
|
||||||
TIM_IMAGE *sprites)
|
TIM_IMAGE *sprites)
|
||||||
{
|
{
|
||||||
|
player->character = character;
|
||||||
player->input = (InputState){ 0 };
|
player->input = (InputState){ 0 };
|
||||||
load_chara(&player->chara, chara_filename, sprites);
|
load_chara(&player->chara, chara_filename, sprites);
|
||||||
player->cur_anim = NULL;
|
player->cur_anim = NULL;
|
||||||
player->tail_cur_anim = NULL;
|
player->tail_cur_anim = NULL;
|
||||||
player->cnst = &CNST_DEFAULT;
|
player->cnst = getconstants(character, PC_DEFAULT);
|
||||||
player->pos = (VECTOR){ 0 };
|
player->pos = (VECTOR){ 0 };
|
||||||
player->vel = (VECTOR){ 0 };
|
player->vel = (VECTOR){ 0 };
|
||||||
player->angle = 0;
|
player->angle = 0;
|
||||||
|
@ -160,7 +158,6 @@ load_player(Player *player,
|
||||||
player->col_ledge = 0;
|
player->col_ledge = 0;
|
||||||
|
|
||||||
player->action = ACTION_NONE;
|
player->action = ACTION_NONE;
|
||||||
player->character = character;
|
|
||||||
|
|
||||||
if(sfx_jump.addr == 0) sfx_jump = sound_load_vag("\\SFX\\JUMP.VAG;1");
|
if(sfx_jump.addr == 0) sfx_jump = sound_load_vag("\\SFX\\JUMP.VAG;1");
|
||||||
if(sfx_skid.addr == 0) sfx_skid = sound_load_vag("\\SFX\\SKIDDING.VAG;1");
|
if(sfx_skid.addr == 0) sfx_skid = sound_load_vag("\\SFX\\SKIDDING.VAG;1");
|
||||||
|
@ -1233,7 +1230,7 @@ player_update(Player *player)
|
||||||
if(player->speedshoes_frames == 0) {
|
if(player->speedshoes_frames == 0) {
|
||||||
// Reset constants.
|
// Reset constants.
|
||||||
// Notice that speedshoes_frames is set to -1 by general level update.
|
// Notice that speedshoes_frames is set to -1 by general level update.
|
||||||
player->cnst = player->underwater ? &CNST_UNDERWATER : &CNST_DEFAULT;
|
player->cnst = getconstants(player->character, player->underwater ? PC_UNDERWATER : PC_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Underwater / leaving water
|
// Underwater / leaving water
|
||||||
|
@ -1245,16 +1242,18 @@ player_update(Player *player)
|
||||||
|
|
||||||
// Change constants accordingly!
|
// Change constants accordingly!
|
||||||
if(player->underwater) { // Entered underwater state
|
if(player->underwater) { // Entered underwater state
|
||||||
player->cnst = &CNST_UNDERWATER;
|
player->cnst = getconstants(player->character, PC_UNDERWATER);
|
||||||
// Halve player's X speed
|
// Halve player's X speed
|
||||||
if(player->grnd) player->vel.vz = player->vel.vz >> 1;
|
if(player->grnd) player->vel.vz = player->vel.vz >> 1;
|
||||||
else player->vel.vx = player->vel.vx >> 1;
|
else player->vel.vx = player->vel.vx >> 1;
|
||||||
// Quarter player's Y speed
|
// Quarter player's Y speed
|
||||||
player->vel.vy = player->vel.vy >> 2;
|
player->vel.vy = player->vel.vy >> 2;
|
||||||
} else {
|
} else {
|
||||||
player->cnst = (player->speedshoes_frames > 0)
|
player->cnst = getconstants(
|
||||||
? &CNST_SPEEDSHOES
|
player->character,
|
||||||
: &CNST_DEFAULT;
|
(player->speedshoes_frames > 0)
|
||||||
|
? PC_SPEEDSHOES
|
||||||
|
: PC_DEFAULT);
|
||||||
// Double Y speed, limiting it to -16.0 (0x00010000)
|
// Double Y speed, limiting it to -16.0 (0x00010000)
|
||||||
player->vel.vy = MAX(player->vel.vy << 1, -0x10000);
|
player->vel.vy = MAX(player->vel.vy << 1, -0x10000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "player_constants.h"
|
#include "player_constants.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
// Default player values
|
// Default player values
|
||||||
PlayerConstants CNST_DEFAULT = {
|
static PlayerConstants CNST_DEFAULT = {
|
||||||
.x_accel = 0x000c0,
|
.x_accel = 0x000c0,
|
||||||
.x_air_accel = 0x00180,
|
.x_air_accel = 0x00180,
|
||||||
.x_friction = 0x000c0,
|
.x_friction = 0x000c0,
|
||||||
|
@ -30,7 +31,7 @@ PlayerConstants CNST_DEFAULT = {
|
||||||
|
|
||||||
// Underwater player values.
|
// Underwater player values.
|
||||||
// Most values are simply halved from base defaults
|
// Most values are simply halved from base defaults
|
||||||
PlayerConstants CNST_UNDERWATER = {
|
static PlayerConstants CNST_UNDERWATER = {
|
||||||
.x_accel = 0x00060, // Changed
|
.x_accel = 0x00060, // Changed
|
||||||
.x_air_accel = 0x000c0, // Changed
|
.x_air_accel = 0x000c0, // Changed
|
||||||
.x_friction = 0x00060, // Changed
|
.x_friction = 0x00060, // Changed
|
||||||
|
@ -58,7 +59,7 @@ PlayerConstants CNST_UNDERWATER = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Speed shoes (only used outside water)
|
// Speed shoes (only used outside water)
|
||||||
PlayerConstants CNST_SPEEDSHOES = {
|
static PlayerConstants CNST_SPEEDSHOES = {
|
||||||
.x_accel = 0x00180, // Changed
|
.x_accel = 0x00180, // Changed
|
||||||
.x_air_accel = 0x00300, // Changed
|
.x_air_accel = 0x00300, // Changed
|
||||||
.x_friction = 0x00180, // Changed
|
.x_friction = 0x00180, // Changed
|
||||||
|
@ -84,3 +85,105 @@ PlayerConstants CNST_SPEEDSHOES = {
|
||||||
.x_hurt_force = 0x02000,
|
.x_hurt_force = 0x02000,
|
||||||
.x_peelout_spd = 0x0c000
|
.x_peelout_spd = 0x0c000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Knuckles values */
|
||||||
|
static PlayerConstants CNST_DEFAULT_K = {
|
||||||
|
.x_accel = 0x000c0,
|
||||||
|
.x_air_accel = 0x00180,
|
||||||
|
.x_friction = 0x000c0,
|
||||||
|
.x_decel = 0x00800,
|
||||||
|
.x_top_spd = 0x06000,
|
||||||
|
.y_gravity = 0x00380,
|
||||||
|
.y_hurt_gravity = 0x00300,
|
||||||
|
.y_min_jump = 0x04000,
|
||||||
|
.y_jump_strength = 0x06000,
|
||||||
|
.x_min_roll_spd = 0x01000,
|
||||||
|
.x_min_uncurl_spd = 0x00800,
|
||||||
|
.x_roll_friction = 0x00060,
|
||||||
|
.x_roll_decel = 0x00200,
|
||||||
|
.x_slope_min_spd = 0x000d0,
|
||||||
|
.x_slope_normal = 0x00200,
|
||||||
|
.x_slope_rollup = 0x00140,
|
||||||
|
.x_slope_rolldown = 0x00500,
|
||||||
|
.x_max_spd = 0x10000,
|
||||||
|
.x_map_slip_spd = 0x02800,
|
||||||
|
.x_drpspd = 0x08000,
|
||||||
|
.x_drpmax = 0x0c000,
|
||||||
|
.y_hurt_force = 0x04000,
|
||||||
|
.x_hurt_force = 0x02000,
|
||||||
|
.x_peelout_spd = 0x0c000
|
||||||
|
};
|
||||||
|
|
||||||
|
static PlayerConstants CNST_UNDERWATER_K = {
|
||||||
|
.x_accel = 0x00060, // Changed
|
||||||
|
.x_air_accel = 0x000c0, // Changed
|
||||||
|
.x_friction = 0x00060, // Changed
|
||||||
|
.x_decel = 0x00400, // Changed
|
||||||
|
.x_top_spd = 0x03000, // Changed
|
||||||
|
.y_gravity = 0x00100, // Changed
|
||||||
|
.y_hurt_gravity = 0x000c0, // Changed, not documented, y_gravity - half diff on default
|
||||||
|
.y_min_jump = 0x02000, // Changed
|
||||||
|
.y_jump_strength = 0x03000, // Changed
|
||||||
|
.x_min_roll_spd = 0x01000,
|
||||||
|
.x_min_uncurl_spd = 0x00800,
|
||||||
|
.x_roll_friction = 0x00030, // Changed
|
||||||
|
.x_roll_decel = 0x00200,
|
||||||
|
.x_slope_min_spd = 0x000d0,
|
||||||
|
.x_slope_normal = 0x00200,
|
||||||
|
.x_slope_rollup = 0x00140,
|
||||||
|
.x_slope_rolldown = 0x00500,
|
||||||
|
.x_max_spd = 0x10000,
|
||||||
|
.x_map_slip_spd = 0x02800,
|
||||||
|
.x_drpspd = 0x08000,
|
||||||
|
.x_drpmax = 0x0c000,
|
||||||
|
.y_hurt_force = 0x02000, // Changed
|
||||||
|
.x_hurt_force = 0x01000, // Changed
|
||||||
|
.x_peelout_spd = 0x05fff // Changed
|
||||||
|
};
|
||||||
|
|
||||||
|
static PlayerConstants CNST_SPEEDSHOES_K = {
|
||||||
|
.x_accel = 0x00180, // Changed
|
||||||
|
.x_air_accel = 0x00300, // Changed
|
||||||
|
.x_friction = 0x00180, // Changed
|
||||||
|
.x_decel = 0x00800,
|
||||||
|
.x_top_spd = 0x0c000, // Changed
|
||||||
|
.y_gravity = 0x00380,
|
||||||
|
.y_hurt_gravity = 0x00300,
|
||||||
|
.y_min_jump = 0x04000,
|
||||||
|
.y_jump_strength = 0x06000,
|
||||||
|
.x_min_roll_spd = 0x01000,
|
||||||
|
.x_min_uncurl_spd = 0x00800,
|
||||||
|
.x_roll_friction = 0x000c0, // Changed
|
||||||
|
.x_roll_decel = 0x00200,
|
||||||
|
.x_slope_min_spd = 0x000d0,
|
||||||
|
.x_slope_normal = 0x00200,
|
||||||
|
.x_slope_rollup = 0x00140,
|
||||||
|
.x_slope_rolldown = 0x00500,
|
||||||
|
.x_max_spd = 0x10000,
|
||||||
|
.x_map_slip_spd = 0x02800,
|
||||||
|
.x_drpspd = 0x08000,
|
||||||
|
.x_drpmax = 0x0c000,
|
||||||
|
.y_hurt_force = 0x04000,
|
||||||
|
.x_hurt_force = 0x02000,
|
||||||
|
.x_peelout_spd = 0x0c000
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
PlayerConstants *
|
||||||
|
getconstants(PlayerCharacter c, PlayerConstantType pct)
|
||||||
|
{
|
||||||
|
if(c == CHARA_KNUCKLES) {
|
||||||
|
switch(pct) {
|
||||||
|
default: return &CNST_DEFAULT_K;
|
||||||
|
case PC_UNDERWATER: return &CNST_UNDERWATER_K;
|
||||||
|
case PC_SPEEDSHOES: return &CNST_SPEEDSHOES_K;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(pct) {
|
||||||
|
default: return &CNST_DEFAULT;
|
||||||
|
case PC_UNDERWATER: return &CNST_UNDERWATER;
|
||||||
|
case PC_SPEEDSHOES: return &CNST_SPEEDSHOES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "demo.h"
|
#include "demo.h"
|
||||||
|
|
||||||
extern int debug_mode;
|
extern int debug_mode;
|
||||||
extern PlayerConstants CNST_DEFAULT;
|
|
||||||
|
|
||||||
static uint8_t level = 0;
|
static uint8_t level = 0;
|
||||||
static PlayerCharacter level_character = CHARA_SONIC;
|
static PlayerCharacter level_character = CHARA_SONIC;
|
||||||
|
@ -300,7 +299,7 @@ screen_level_update(void *d)
|
||||||
player.vel.vx = player.vel.vy = player.vel.vz = 0;
|
player.vel.vx = player.vel.vy = player.vel.vz = 0;
|
||||||
player.psmode = player.gsmode = CDIR_FLOOR;
|
player.psmode = player.gsmode = CDIR_FLOOR;
|
||||||
player.underwater = 0;
|
player.underwater = 0;
|
||||||
player.cnst = &CNST_DEFAULT;
|
player.cnst = getconstants(player.character, PC_DEFAULT);
|
||||||
player.speedshoes_frames = (player.speedshoes_frames > 0) ? 0 : -1;
|
player.speedshoes_frames = (player.speedshoes_frames > 0) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue