From 7802d35727fa60bcda551ca920ce0bfe3738ae1c Mon Sep 17 00:00:00 2001 From: SemvdH Date: Tue, 20 Apr 2021 00:12:40 +0200 Subject: [PATCH] [ADD] sprites .h and .c files for loading sprites --- .gitignore | 3 ++- src/sprites/sprites.c | 16 ++++++++++++++++ src/sprites/sprites.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/sprites/sprites.c create mode 100644 src/sprites/sprites.h diff --git a/.gitignore b/.gitignore index 5e7cac0..7a2686b 100644 --- a/.gitignore +++ b/.gitignore @@ -75,7 +75,8 @@ CMakeUserPresets.json *-prefix/ ### vscode ### -.vscode/* +.vscode/ +.vscode/** !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json diff --git a/src/sprites/sprites.c b/src/sprites/sprites.c new file mode 100644 index 0000000..773b005 --- /dev/null +++ b/src/sprites/sprites.c @@ -0,0 +1,16 @@ +#include +#include + +#include + +#include "sprites.h" + +#define printf psvDebugScreenPrintf + +void sprites_draw_bullet(BULLET *bullet) +{ + if (bullet->active) + { + vita2d_draw_rectangle(bullet->x, bullet->y, (float)5, (float)10, bullet->color); + } +} \ No newline at end of file diff --git a/src/sprites/sprites.h b/src/sprites/sprites.h new file mode 100644 index 0000000..82697b7 --- /dev/null +++ b/src/sprites/sprites.h @@ -0,0 +1,30 @@ +#ifndef SPRITES_H +#define SPRITES_H + +//TODO draw main player sprite +typedef struct player_sprite_t +{ + /* data */ +} PLAYER; + +/** + * @brief a struct that holds a bullet sprite, basically a rectangle + * there will be at most a few bullets available + */ +typedef struct bullet_sprite_t +{ + size_t active; // whether or not the bullet should be drawn (0 or 1) + float x; // the x position + float y; // the y position + unsigned int color; // color of the bullet +} BULLET; + +/** + * @brief function that draws the given bullet, if it is active + * + * @param bullet the bullet struct pointer that points to the bullet that should be drawn + */ +void sprites_draw_bullet(BULLET *bullet); + + +#endif \ No newline at end of file