diff options
author | zlago | 2024-10-06 19:54:24 +0200 |
---|---|---|
committer | zlago | 2024-10-06 21:23:44 +0200 |
commit | d005a7756f6d15f67a7033a53bae23d00a58af69 (patch) | |
tree | db6abbabdbfd1ca7d3c32756042623052c43a0ce /src/entity.h | |
parent | a887634f473b9e665c54f223e24080a1492c58fe (diff) |
particles and projectiles
Diffstat (limited to 'src/entity.h')
-rw-r--r-- | src/entity.h | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/src/entity.h b/src/entity.h index fe76feb..0166bdc 100644 --- a/src/entity.h +++ b/src/entity.h @@ -5,23 +5,29 @@ #define from_fixed(a) (a / 16) #define to_fixed(a) (a * 16) +struct vec2 { + signed x, y; +}; + +struct hitbox { + unsigned left, right, top, bottom; +}; + +struct anim { + unsigned frame; + SDL_Rect rect; + unsigned length; +}; + struct entity { int (*update)(struct entity *self); int (*hurt)(struct entity *self, int damage); int (*draw)(struct entity *self, int camx, int camy); void (*free)(struct entity *self); int x, y; // unsigned results in a bunch of weird edge cases - struct velocity { - signed x, y; - } velocity; - struct hitbox { - unsigned left, right, top, bottom; - } hitbox; - struct anim { - unsigned frame; - SDL_Rect rect; - unsigned length; - } anim; + struct vec2 velocity; + struct hitbox hitbox; + struct anim anim; unsigned state; int hp; int timer; @@ -40,3 +46,28 @@ struct warp { unsigned timer; void *ext; }; + +struct projectile { + int (*update)(struct projectile *self); + int (*draw)(struct projectile *self, int camx, int camy); + void (*free)(struct projectile *self); + int x, y; // unsigned results in a bunch of weird edge cases + struct vec2 velocity; + struct hitbox hitbox; + struct anim anim; + unsigned state; + int hp; + int timer; + int iframes; + signed facing; + void *texture; + void *ext; +}; + +struct particle { + int x, y; + struct vec2 velocity; + struct vec2 acceleration; + SDL_Rect rect; + int hp; +}; |