From daf7317c08aaf9cd68762ba6f0d6704702dffd35 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Tue, 4 Mar 2025 21:02:55 -0500 Subject: [PATCH] Enemy is a rollerskate --- enemy.c | 11 ++++++++++- img/enemy.aseprite | Bin 0 -> 625 bytes img/enemy.png | Bin 0 -> 793 bytes 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 img/enemy.aseprite create mode 100644 img/enemy.png diff --git a/enemy.c b/enemy.c index 4af65a2..971ecbe 100644 --- a/enemy.c +++ b/enemy.c @@ -14,7 +14,15 @@ #include "enemy.h" #include "entity.h" +Texture2D *enemy_sprite = NULL; + Entity *spawn_enemy(void) { + if (enemy_sprite == NULL) { + enemy_sprite = malloc(sizeof(Texture2D)); + Image sprite_img = LoadImage("img/enemy.png"); + *enemy_sprite = LoadTextureFromImage(sprite_img); + UnloadImage(sprite_img); + } Entity *e = malloc(sizeof(Entity)); e->name = "Enemy"; e->properties = malloc(sizeof(Entity)); @@ -35,7 +43,8 @@ Entity *spawn_enemy(void) { void draw_enemy(Entity *e) { EnemyProperties *props = e->properties; - DrawRectangleRec(props->position, RED); + // DrawRectangleRec(props->position, RED); + DrawTextureRec(*enemy_sprite, (Rectangle) { props->velocity.x > 0 ? 32 : 0, 0, 32, 32 }, (Vector2) { props->position.x, props->position.y }, WHITE); } void update_position_enemy(Entity *e, float dt) { diff --git a/img/enemy.aseprite b/img/enemy.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..266b5a9ce62558a9e92ca39316fbc90d56e68567 GIT binary patch literal 625 zcmXS9Vqkc%l#zjfk%3VGNH8#@05Jjp#Xy1#3P4B;@DXVGua7KXTUme>hygLX0@z9< z>#~4s7Le-{fD9!C6ITtJG)u$&Fzfq;YBv|8y*oVX_b0QNPXn^{8JJJW^Ul-{@>Vgj zv9z}@F-T~N&U=_V`+xk|C#P@!`Tzg_?6uol>e@52vLeHR%AC5^7#ZCRPrhEgtADyz zSH6Kf$R-75APEEifedyApTx@4A_YS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