calculate spike angle once per frame

This commit is contained in:
kdx 2023-03-21 21:31:26 +01:00
parent a262d35146
commit 96163690d4
3 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,8 @@ game_deinit(Game *this)
void
game_update(Game *this)
{
extern double tick;
this->spike_angle = tick / 16;
if (this->queue_restart_scene > 0) {
if (--this->queue_restart_scene == 0)
game_restart_scene(this);

View File

@ -8,6 +8,7 @@ typedef struct Game {
bool queue_next_scene;
int queue_restart_scene;
int player_dir;
double spike_angle;
Entity entities[MAX_ENTITIES];
} Game;

View File

@ -7,9 +7,8 @@ IMPL_UPDATE() {
} IMPL_END
IMPL_DRAW() {
const double angle = tick / 16;
rotrect(this->pos[0], this->pos[1], 10, 10, angle);
rotrect(this->pos[0], this->pos[1], 10, 10, -angle);
rotrect(this->pos[0], this->pos[1], 10, 10, g->spike_angle);
rotrect(this->pos[0], this->pos[1], 10, 10, -g->spike_angle);
} IMPL_END
IMPL_INIT(spike) {