aboutsummaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-07-28 22:15:15 +0000
committerrodri <rgl@antares-labs.eu>2021-07-28 22:15:15 +0000
commit9942eb201a657640cf244b261008b850352a29f3 (patch)
tree43ffc43f9c3fd9dd6e45e835cea0a87381ae16da /dat.h
parentd85705bf67be2a23e3d928f9670732be5484f958 (diff)
downloadmusw-9942eb201a657640cf244b261008b850352a29f3.tar.gz
musw-9942eb201a657640cf244b261008b850352a29f3.tar.bz2
musw-9942eb201a657640cf244b261008b850352a29f3.zip
brought the Sprite struct for future animations.
implemented per-party game state and dynamics. now the state is broadcast after integration, not before. fixed a bug in the broadcast procedure where it would keep referencing an already freed Party and its players. implemented a proper Keymap the user will be able to configure. added mkfile rules to manage installation and dependencies. defined a ton of structs in dat.h for new game objects. started work on a general vector model abstraction to define ship `skins'. removed some debug clauses we no longer need. fixed some other ones.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/dat.h b/dat.h
index 643216e..33c4607 100644
--- a/dat.h
+++ b/dat.h
@@ -1,3 +1,28 @@
+typedef enum
+{
+ K↑,
+ K↺,
+ K↻,
+ Kfire,
+ Khyper,
+ Ksay,
+ Kquit,
+ NKEYOPS
+} KeyOp;
+
+typedef enum
+{
+ NEEDLE,
+ WEDGE
+} Kind;
+
+typedef struct Vector Vector;
+typedef struct VModel VModel;
+typedef struct Sprite Sprite;
+typedef struct Particle Particle;
+typedef struct Ship Ship;
+typedef struct Star Star;
+typedef struct Universe Universe;
typedef struct GameState GameState;
typedef struct Derivative Derivative;
typedef struct Conn Conn;
@@ -5,8 +30,72 @@ typedef struct Player Player;
typedef struct Lobby Lobby;
typedef struct Party Party;
+struct Vector
+{
+ double x, y;
+};
+
+/*
+ * Vector model - made out of lines and curves
+ */
+struct VModel
+{
+ Vector *pts;
+ ulong npts;
+ /* WIP
+ * l(ine) → takes 2 points
+ * c(urve) → takes 3 points
+ */
+// char *strokefmt;
+};
+
+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);
+};
+
+struct Particle
+{
+ Vector p, v;
+ double yaw;
+ double mass;
+};
+
+struct Ship
+{
+ Particle;
+ Kind kind;
+ uint ammo;
+ VModel *mdl;
+// Matrix mdlxform;
+};
+
+struct Star
+{
+ Particle;
+ Sprite spr;
+};
+
+struct Universe
+{
+ Ship ships[2];
+ Star star;
+
+ int (*step)(Universe*);
+};
+
struct GameState
{
+ double t, timeacc;
double x, v;
};
@@ -43,7 +132,12 @@ struct Lobby
struct Party
{
Player players[2]; /* the needle and the wedge */
+ Universe *u;
Party *prev, *next;
+
+ /* testing */
+ GameState state;
};
+
extern Party theparty;