From 1546beac329d017b86331d0acd2dd0dd86101506 Mon Sep 17 00:00:00 2001 From: rodri Date: Fri, 12 Mar 2021 11:37:09 +0000 Subject: implemented fixed-time dynamics stepper, animated sprites and cleaned things up. --- dat.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'dat.h') diff --git a/dat.h b/dat.h index 4dd4250..a3065ee 100644 --- a/dat.h +++ b/dat.h @@ -1,6 +1,7 @@ -typedef struct State State; +typedef struct GameState GameState; typedef struct Derivative Derivative; typedef struct Stats Stats; +typedef struct Sprite Sprite; struct Stats { @@ -12,7 +13,7 @@ struct Stats void (*update)(Stats*, double); }; -struct State +struct GameState { double x, v; Stats stats; @@ -22,3 +23,17 @@ struct Derivative { double dx, dv; }; + +struct Sprite +{ + Image *sheet; + Point sp; + Rectangle r; + int nframes; + int curframe; + ulong period; + ulong elapsed; + + void (*step)(Sprite*, ulong); + void (*draw)(Sprite*, Image*, Point); +}; -- cgit v1.2.3