self->base.jumpable_frames = 0;
}
+static void jumpnrun_enemy_kill(jumpnrun_enemy *self) {
+ self->base.flags |= JUMPNRUN_MOVEABLE_DYING;
+ self->base.tick_minor = 0;
+}
+
void jumpnrun_enemy_despawn(jumpnrun_enemy *self) {
// Despawned enemies are reset to their spawn position, so enemy_in_spawn_area will determine whether the spawn point is in the spawn area.
- self->base.flags &= ~(JUMPNRUN_ENEMY_SPAWNED | JUMPNRUN_ENEMY_MOVING);
+ self->base.flags &= ~(JUMPNRUN_ENEMY_SPAWNED | JUMPNRUN_ENEMY_MOVING | JUMPNRUN_MOVEABLE_DYING);
self->base.hitbox = rectangle_new(self->spawn_pos, self->type->hitbox.extent);
self->base.inertia = self->type->spawn_inertia;
}
if(self->base.flags & JUMPNRUN_ENEMY_SPAWNED) {
if(!enemy_in_spawn_area(self, state) || fixed_point_gt(rectangle_top (enemy_hitbox(self)), FIXED_INT(BADGE_DISPLAY_HEIGHT))) {
jumpnrun_enemy_despawn(self);
+ } else if(self->base.flags & JUMPNRUN_MOVEABLE_DYING) {
+ if(self->base.tick_minor == JUMPNRUN_SPLOSION_FRAMES * JUMPNRUN_SPLOSION_TICKS_PER_FRAME) {
+ jumpnrun_enemy_despawn(self);
+ } else {
+ if(fb) {
+ jumpnrun_render_splosion(fb, state, &self->base);
+ }
+ ++self->base.tick_minor;
+ }
} else {
if((self->base.flags & JUMPNRUN_ENEMY_MOVING) || enemy_on_screen(self, state)) {
self->base.flags |= JUMPNRUN_ENEMY_MOVING;
&inertia_mod);
if(killed) {
- jumpnrun_enemy_despawn(self);
+ jumpnrun_enemy_kill(self);
} else if(fixed_point_ne(inertia_mod.x, self->base.inertia.x)) {
enemy_bounce(self);
}
if(fixed_point_lt(rectangle_top(&state->player.base.hitbox), rectangle_top(enemy_hitbox(self))) &&
fixed_point_gt(state->player.base.inertia.y, FIXED_INT(0)))
{
- jumpnrun_enemy_despawn(self);
+ jumpnrun_enemy_kill(self);
player_inertia_mod->y = FIXED_POINT(0, -250);
state->player.base.jumpable_frames = 12;
} else {
if(jumpnrun_shot_spawned(shot)) {
if(rectangle_intersect(enemy_hitbox(self), &shot->current_box)) {
- self->base.flags &= ~JUMPNRUN_ENEMY_SPAWNED;
+ jumpnrun_enemy_kill(self);
jumpnrun_shot_despawn(shot);
}
}
+smb
skynet
wrongturn
-smb
lubiXOXO
lubilove
gnobbel
enum {
// Do not collide with JUMPNRUN_ENEMY_* and JUMPNRUN_PLAYER_* flags.
JUMPNRUN_MOVEABLE_TOUCHING_GROUND = 1,
- JUMPNRUN_MOVEABLE_MIRRORED = 2
+ JUMPNRUN_MOVEABLE_MIRRORED = 2,
+ JUMPNRUN_MOVEABLE_DYING = 4
};
typedef struct jumpnrun_moveable {
{ 3, 3, (uint8_t const *) "\xee" }
};
-static badge_sprite const anim_player[JUMPNRUN_PLAYER_FRAMES ] = {
+static badge_sprite const anim_player[JUMPNRUN_PLAYER_FRAMES] = {
{ 5, 8, (uint8_t const *) "\x1c\xff\xfd\x04\x04" },
{ 5, 8, (uint8_t const *) "\x1c\xff\x3d\xc4\x04" },
{ 5, 8, (uint8_t const *) "\xdc\x3f\x1d\x24\xc4" },
{ 5, 8, (uint8_t const *) "\x1c\xff\x3d\xc4\x04" }
};
+static badge_sprite const anim_splosion[JUMPNRUN_SPLOSION_FRAMES] = {
+ { 7, 5, (uint8_t const *) "\x00\x28\xa0\x00" },
+ { 7, 5, (uint8_t const *) "\x51\x29\xa0\x54\x04" },
+ { 7, 5, (uint8_t const *) "\x51\x01\x00\x54\x04" },
+ { 7, 5, (uint8_t const *) "\x11\x00\x00\x40\x04" }
+};
+
vec2d jumpnrun_player_extents(void) { return (vec2d) { FIXED_INT_I(5), FIXED_INT_I(8) }; }
void jumpnrun_render_moveable (badge_framebuffer *fb, jumpnrun_game_state const *state, jumpnrun_moveable const *moveable, badge_sprite const *animation, vec2d sprite_offset) {
0);
}
+void jumpnrun_render_splosion (badge_framebuffer *fb, jumpnrun_game_state const *state, jumpnrun_moveable const *moveable) {
+ badge_sprite const *sprite = &anim_splosion[moveable->tick_minor / JUMPNRUN_SPLOSION_TICKS_PER_FRAME];
+ vec2d sprite_offset = {
+ fixed_point_div(fixed_point_sub(FIXED_INT(sprite->width ), rectangle_width (&moveable->hitbox)), FIXED_INT(2)),
+ fixed_point_div(fixed_point_sub(FIXED_INT(sprite->height), rectangle_height(&moveable->hitbox)), FIXED_INT(2))
+ };
+ vec2d render_pos = vec2d_sub(moveable->hitbox.pos, sprite_offset);
+
+ badge_framebuffer_blt(fb,
+ fixed_point_cast_int(render_pos.x) - jumpnrun_screen_left(state),
+ fixed_point_cast_int(render_pos.y),
+ sprite, 0);
+}
+
void jumpnrun_render_player_symbol(badge_framebuffer *fb, int8_t x, int8_t y) {
badge_framebuffer_blt(fb, x, y, &anim_player[0], 0);
}
void jumpnrun_render_tile (badge_framebuffer *fb, jumpnrun_game_state const *state, jumpnrun_tile const *tile );
void jumpnrun_render_item (badge_framebuffer *fb, jumpnrun_game_state const *state, jumpnrun_item const *item );
+void jumpnrun_render_splosion (badge_framebuffer *fb, jumpnrun_game_state const *state, jumpnrun_moveable const *moveable);
+
void jumpnrun_render_player_symbol(badge_framebuffer *fb, int8_t x, int8_t y);
void jumpnrun_render_key_symbol (badge_framebuffer *fb, int8_t x, int8_t y);
+enum {
+ JUMPNRUN_SPLOSION_FRAMES = 4,
+ JUMPNRUN_SPLOSION_TICKS_PER_FRAME = 15
+};
+
#endif