anim speed, red platform color, invincibility hack, details

This commit is contained in:
Lephenixnoir 2023-06-02 08:47:19 +02:00
parent 0e62ad062d
commit cde90744cf
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
6 changed files with 47 additions and 22 deletions

View File

@ -58,17 +58,21 @@ void player::get_anim(struct anim **anim, int *frame)
extern struct anim anim_erik_running;
extern struct anim anim_erik_jumping;
num vanim = num(1) + this->energy_percent / 200;
if(this->stance == Running) {
this->frame = (this->frame + 1) % anim_erik_running.frame_count;
this->frame = this->frame + vanim;
if(this->frame >= anim_erik_running.frame_count)
this->frame = 0;
*anim = &anim_erik_running;
*frame = this->frame;
*frame = (int)this->frame;
}
else {
this->frame++;
this->frame = this->frame + vanim;
if(this->frame >= anim_erik_jumping.frame_count)
this->frame = 12;
*anim = &anim_erik_jumping;
*frame = this->frame;
*frame = (int)this->frame;
}
}

View File

@ -31,8 +31,8 @@ struct player
/* Determine the player's animation and frame. */
void get_anim(struct anim **anim, int *frame);
/* Current animation frame. */
int frame;
/* Current animation frame (fractional for variable animation speed). */
num frame;
/* Whether the player is airborne. */
bool airborne() const { return this->stance != Running; }
@ -87,7 +87,8 @@ struct game
int sections_passed;
struct {
bool footer; /* Show performance footer */
bool footer; /* Show performance footer */
bool invincible; /* Invincibility hack */
} debug;
struct {

View File

@ -38,6 +38,7 @@ struct MultiPathCarver
{
/* Create a carver with a set number of parallel paths. */
MultiPathCarver(int N);
~MultiPathCarver();
/* Set initial positions. */
void set_faces(int *faces /* size N */);
@ -55,15 +56,17 @@ struct MultiPathCarver
void next(struct level *level, num z, num length);
private:
/* Number of parallel paths */
int m_N;
/* Information specific to each path */
struct {
struct Path {
/* Current face */
int face;
/* Whether last platform was skipped */
bool last_skipped;
} *m_paths;
};
/* Number of parallel paths */
int m_N;
/* Information specific to each path */
Path *m_paths;
/* Force all platforms to be generated */
bool m_noskip;
/* Force a checkerboard pattern */

View File

@ -42,14 +42,19 @@ void path_carver::teleport(num z)
MultiPathCarver::MultiPathCarver(int N)
{
m_N = N;
m_paths = static_cast<decltype(m_paths)>(malloc(N * sizeof *m_paths));
m_paths = new Path[m_N];
m_noskip = false;
m_checkerboard = false;
for(int i = 0; i < N; i++)
for(int i = 0; i < m_N; i++)
m_paths[i].last_skipped = false;
}
MultiPathCarver::~MultiPathCarver()
{
delete[] m_paths;
}
void MultiPathCarver::set_faces(int *faces)
{
for(int i = 0; i < m_N; i++)

View File

@ -26,6 +26,7 @@ int play_level(int level_id)
game.t = 0.0;
game.sections_passed = 0;
game.debug.footer = false;
game.debug.invincible = false;
camera->set_fov(120.0);
camera->screen_size = vec2(DWIDTH, DHEIGHT);
@ -38,7 +39,7 @@ int play_level(int level_id)
player->jump_t = 0.0;
player->height = 1.0;
player->vheight = 0.0;
player->frame = 0;
player->frame = 0.0;
player->energy_percent = 0.0;
/* Input buffering */
@ -157,6 +158,10 @@ int play_level(int level_id)
game_run = false;
if(key == KEY_OPTN)
game.debug.footer = !game.debug.footer;
#if 0
if(key == KEY_VARS)
game.debug.invincible = !game.debug.invincible;
#endif
if(key == KEY_LEFT)
keybuffer.left = 8;
@ -181,7 +186,7 @@ int play_level(int level_id)
player->jump_t = 0.0;
player->jump_key = key;
player->vheight = JUMP_THRUST;
player->frame = 0;
player->frame = 0.0;
keybuffer.left = 0;
keybuffer.right = 0;
@ -234,15 +239,19 @@ int play_level(int level_id)
player->vheight = -1;
}
if(player->height >= floor - STEP_HEIGHT
&& player->height <= floor) {
if((player->height >= floor - STEP_HEIGHT
&& player->height <= floor)
|| (game.debug.invincible && player->height < 0)) {
player->stance = player::Running;
player->jump_dir = 0;
player->jump_t = 0.0;
player->height = floor;
player->vheight = 0;
player->jump_key = 0;
player->frame = 0;
player->frame = 0.0;
if(game.debug.invincible && player->height < 0)
player->height = 0;
}
}
else if(floor < player->height) {
@ -256,7 +265,7 @@ int play_level(int level_id)
/* Death condition #2/2: below the kill plane */
bool death_2 = (player->height < LEVEL_RADIUS - KILL_PLANE_RADIUS);
if(death_1 || death_2)
if(!game.debug.invincible && (death_1 || death_2))
break;
if(standing_on && standing_on->type == PLATFORM_BLUE) {

View File

@ -136,8 +136,11 @@ uint16_t render_platform_color(struct platform const *p,
return camera_platform_color(camera, p->face);
if(p->type == PLATFORM_BLUE)
return render_color_blue_platform(t);
if(p->type == PLATFORM_RED)
return RGB24(0xd06060);
if(p->type == PLATFORM_RED) {
return t.frac() >= num(0.6)
? camera_platform_color(camera, p->face)
: RGB24(0xd06060);
}
return RGB24(0xff00ff);
}