diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-17 20:51:15 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-17 20:51:15 +0100 |
commit | c237c7756176cd1522bbcff50e8b9baaaefbc2fa (patch) | |
tree | 8a35d4627a4b60a5ed039547fdc8f8cd20d5cfe1 | |
parent | f7f7d4f9d1828a481841f18f0884a8bc223b3cfc (diff) | |
download | hyperultra-c237c7756176cd1522bbcff50e8b9baaaefbc2fa.tar.gz |
spawn exit
-rw-r--r-- | src/entity.h | 5 | ||||
-rw-r--r-- | src/exit.c | 29 | ||||
-rw-r--r-- | src/exit.h | 10 | ||||
-rw-r--r-- | src/game.c | 4 |
4 files changed, 47 insertions, 1 deletions
diff --git a/src/entity.h b/src/entity.h index a1594e7..be8fc0b 100644 --- a/src/entity.h +++ b/src/entity.h @@ -1,12 +1,14 @@ #pragma once #include "player.h" +#include "exit.h" #include <stdbool.h> struct Game; typedef enum { ET_NONE, - ET_PLAYER + ET_PLAYER, + ET_EXIT } EntityType; typedef struct Entity Entity; @@ -24,6 +26,7 @@ struct Entity { bool solid; union { Player player; + Exit exit; }; }; diff --git a/src/exit.c b/src/exit.c new file mode 100644 index 0000000..713ed18 --- /dev/null +++ b/src/exit.c @@ -0,0 +1,29 @@ +#include "exit.h" +#include "entity.h" +#include "game.h" +#include "cfg.h" +#include "lzy.h" +#include <string.h> + +static void +exit_draw(Entity *this, Game *g) +{ + (void)g; + LZY_DrawSetColor(BLACK); + LZY_DrawRect(this->pos[0] - this->width / 2, + this->pos[1] - this->height / 2, + this->width, this->height); +} + +void +exit_init(Entity *this, int x, int y) +{ + memset(this, 0, sizeof(*this)); + this->pos[0] = x; + this->pos[1] = y; + this->type = ET_EXIT; + this->update = NULL; + this->draw = exit_draw; + this->width = 12; + this->height = 12; +} diff --git a/src/exit.h b/src/exit.h new file mode 100644 index 0000000..8b4ed04 --- /dev/null +++ b/src/exit.h @@ -0,0 +1,10 @@ +#pragma once + +typedef struct { + int _; +} Exit; + +struct Entity; +struct Game; + +void exit_init(struct Entity *this, int x, int y); @@ -1,4 +1,5 @@ #include "game.h" +#include "exit.h" #include "map.h" #include "player.h" #include "cfg.h" @@ -50,6 +51,9 @@ game_restart_scene(Game *this) case 2: player_init(game_create_entity(this), dx, dy); break; + case 4: + exit_init(game_create_entity(this), dx, dy); + break; default: break; } |