mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] [th05] Bosses: Start a new header for implementation macros
Part of P0189, funded by Arandui and Lmocinemod.
This commit is contained in:
parent
3836a8d262
commit
71b6e66fec
|
@ -13,6 +13,7 @@
|
|||
#include "th05/sprites/main_pat.h"
|
||||
#include "th04/main/playfld.hpp"
|
||||
#include "th05/main/boss/boss.hpp"
|
||||
#include "th05/main/boss/impl.hpp"
|
||||
|
||||
#define mai boss
|
||||
#define yuki boss2
|
||||
|
|
|
@ -36,66 +36,6 @@ static const int BOSS_FLYSTEP_RANDOM_FRAMES = 28;
|
|||
// function returns true.
|
||||
bool pascal near boss_flystep_random(int frame);
|
||||
|
||||
#define flystep_random_for( \
|
||||
boss, \
|
||||
next_y_direction, \
|
||||
speed, \
|
||||
frames, \
|
||||
clamp_left, \
|
||||
clamp_right, \
|
||||
clamp_top, \
|
||||
clamp_bottom, \
|
||||
sprite_left, \
|
||||
sprite_right, \
|
||||
sprite_still, \
|
||||
frame \
|
||||
) \
|
||||
if(frame == 0) { \
|
||||
if(boss.pos.cur.x.v < BOSS_FLYSTEP_RANDOM_FIELD_LEFT) { \
|
||||
boss.angle = (randring2_next16_mod(0x60) - 0x30); \
|
||||
} else if(boss.pos.cur.x.v > BOSS_FLYSTEP_RANDOM_FIELD_RIGHT) { \
|
||||
boss.angle = (randring2_next16_and(0x60) + 0x30); \
|
||||
} else { \
|
||||
boss.angle = randring2_next16(); \
|
||||
} \
|
||||
if( \
|
||||
(next_y_direction == Y_UP ) && (boss.angle < 0x80) || \
|
||||
(next_y_direction == Y_DOWN) && (boss.angle >= 0x80) \
|
||||
) { \
|
||||
boss.angle = -boss.angle; \
|
||||
} \
|
||||
next_y_direction = Y_ANY; \
|
||||
} \
|
||||
if(frame >= 0) { \
|
||||
vector2_near( \
|
||||
boss.pos.velocity, boss.angle, (to_sp(speed) - (frame * 2)) \
|
||||
); \
|
||||
boss.pos.cur.x.v += boss.pos.velocity.x.v; \
|
||||
boss.pos.cur.y.v += boss.pos.velocity.y.v; \
|
||||
if(boss.pos.velocity.x.v < 0) { \
|
||||
boss.sprite = sprite_left; \
|
||||
} else { \
|
||||
boss.sprite = sprite_right; \
|
||||
} \
|
||||
if(boss.pos.cur.y.v < clamp_top) { \
|
||||
boss.pos.cur.y.v = clamp_top; \
|
||||
next_y_direction = Y_DOWN; \
|
||||
} else if(boss.pos.cur.y.v > clamp_bottom) { \
|
||||
boss.pos.cur.y.v = clamp_bottom; \
|
||||
next_y_direction = Y_UP; \
|
||||
} \
|
||||
if(boss.pos.cur.x.v < clamp_left) { \
|
||||
boss.pos.cur.x.v = clamp_left; \
|
||||
} else if(boss.pos.cur.x.v > clamp_right) { \
|
||||
boss.pos.cur.x.v = clamp_right; \
|
||||
} \
|
||||
if(frame >= frames) { \
|
||||
boss.sprite = sprite_still; \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
return false;
|
||||
|
||||
// Steps the [boss] from its current position towards the target point, moving
|
||||
// it by a hardcoded fraction of the distance. Returns true once the [boss]
|
||||
// has reached the target point.
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
// Shared boss implementation macros.
|
||||
|
||||
#define flystep_random_for( \
|
||||
boss, \
|
||||
next_y_direction, \
|
||||
speed, \
|
||||
frames, \
|
||||
clamp_left, \
|
||||
clamp_right, \
|
||||
clamp_top, \
|
||||
clamp_bottom, \
|
||||
sprite_left, \
|
||||
sprite_right, \
|
||||
sprite_still, \
|
||||
frame \
|
||||
) { \
|
||||
if(frame == 0) { \
|
||||
if(boss.pos.cur.x.v < BOSS_FLYSTEP_RANDOM_FIELD_LEFT) { \
|
||||
boss.angle = (randring2_next16_mod(0x60) - 0x30); \
|
||||
} else if(boss.pos.cur.x.v > BOSS_FLYSTEP_RANDOM_FIELD_RIGHT) { \
|
||||
boss.angle = (randring2_next16_and(0x60) + 0x30); \
|
||||
} else { \
|
||||
boss.angle = randring2_next16(); \
|
||||
} \
|
||||
if( \
|
||||
(next_y_direction == Y_UP ) && (boss.angle < 0x80) || \
|
||||
(next_y_direction == Y_DOWN) && (boss.angle >= 0x80) \
|
||||
) { \
|
||||
boss.angle = -boss.angle; \
|
||||
} \
|
||||
next_y_direction = Y_ANY; \
|
||||
} \
|
||||
if(frame >= 0) { \
|
||||
vector2_near( \
|
||||
boss.pos.velocity, boss.angle, (to_sp(speed) - (frame * 2)) \
|
||||
); \
|
||||
boss.pos.cur.x.v += boss.pos.velocity.x.v; \
|
||||
boss.pos.cur.y.v += boss.pos.velocity.y.v; \
|
||||
if(boss.pos.velocity.x.v < 0) { \
|
||||
boss.sprite = sprite_left; \
|
||||
} else { \
|
||||
boss.sprite = sprite_right; \
|
||||
} \
|
||||
if(boss.pos.cur.y.v < clamp_top) { \
|
||||
boss.pos.cur.y.v = clamp_top; \
|
||||
next_y_direction = Y_DOWN; \
|
||||
} else if(boss.pos.cur.y.v > clamp_bottom) { \
|
||||
boss.pos.cur.y.v = clamp_bottom; \
|
||||
next_y_direction = Y_UP; \
|
||||
} \
|
||||
if(boss.pos.cur.x.v < clamp_left) { \
|
||||
boss.pos.cur.x.v = clamp_left; \
|
||||
} else if(boss.pos.cur.x.v > clamp_right) { \
|
||||
boss.pos.cur.x.v = clamp_right; \
|
||||
} \
|
||||
if(frame >= frames) { \
|
||||
boss.sprite = sprite_still; \
|
||||
return true; \
|
||||
} \
|
||||
} \
|
||||
return false; \
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
#include "th05/main/boss/impl.hpp"
|
||||
|
||||
extern y_direction_t boss_flystep_random_next_y_direction;
|
||||
|
||||
bool pascal near boss_flystep_random(int frame)
|
||||
|
|
Loading…
Reference in New Issue