summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-21 21:31:26 +0100
committerkdx <kikoodx@paranoici.org>2023-03-21 21:31:26 +0100
commit96163690d49f7856c462378b7ea3771d101f0bba (patch)
tree61edd83f378fb33bed52b0fce710b39748bacbb3
parenta262d351465957eadba265f1c3976e202e5b768d (diff)
downloadhyperultra-96163690d49f7856c462378b7ea3771d101f0bba.tar.gz
calculate spike angle once per frame
-rw-r--r--src/game.c2
-rw-r--r--src/game.h1
-rw-r--r--src/spike.c5
3 files changed, 5 insertions, 3 deletions
diff --git a/src/game.c b/src/game.c
index 877385a..31ac01b 100644
--- a/src/game.c
+++ b/src/game.c
@@ -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);
diff --git a/src/game.h b/src/game.h
index 001d467..b8dae9f 100644
--- a/src/game.h
+++ b/src/game.h
@@ -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;
diff --git a/src/spike.c b/src/spike.c
index 3c5a8d3..f09537f 100644
--- a/src/spike.c
+++ b/src/spike.c
@@ -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) {