From 09438266c3987c89a1e7f0abf9042dd3528ac343 Mon Sep 17 00:00:00 2001 From: kdx Date: Sun, 26 Mar 2023 07:26:47 +0000 Subject: overengineer entityimpl a bit more --- src/player.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/player.c') diff --git a/src/player.c b/src/player.c index 5456d0f..9434b3c 100644 --- a/src/player.c +++ b/src/player.c @@ -5,6 +5,22 @@ #include "rotrect.h" #include +IMPL_INIT(player) { + this->width = 10; + this->height = 10; + this->player.scale_x = 1.0; + this->player.scale_y = 1.0; + this->player.dirx = 1; +} + +IMPL(draw) { + LZY_DrawSetColor(BLACK); + const double width = this->width * this->player.scale_x + 2; + const double height = this->height * this->player.scale_y + 2; + rotrect(this->pos[0] - 1, this->pos[1] - 1, + width, height, this->player.angle); +} + IMPL(update) { const int on_ground = entity_collide(this, g, 0, 1); @@ -72,19 +88,3 @@ IMPL(update) { if (entity_place_meeting(this, g, entity_type("exit")) != NULL) g->queue_next_scene = true; } - -IMPL(draw) { - LZY_DrawSetColor(BLACK); - const double width = this->width * this->player.scale_x + 2; - const double height = this->height * this->player.scale_y + 2; - rotrect(this->pos[0] - 1, this->pos[1] - 1, - width, height, this->player.angle); -} - -IMPL_INIT(player) { - this->width = 10; - this->height = 10; - this->player.scale_x = 1.0; - this->player.scale_y = 1.0; - this->player.dirx = 1; -} IMPL_END -- cgit v1.2.3