From 9942eb201a657640cf244b261008b850352a29f3 Mon Sep 17 00:00:00 2001 From: rodri Date: Wed, 28 Jul 2021 22:15:15 +0000 Subject: 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. --- musw.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'musw.c') diff --git a/musw.c b/musw.c index feba719..39c707a 100644 --- a/musw.c +++ b/musw.c @@ -7,23 +7,24 @@ #include "dat.h" #include "fns.h" -enum { - K↑, - K←, - K→, - Kfire, - Khyper, - Kquit, - NKEYS +typedef struct Keymap Keymap; +struct Keymap +{ + Rune key; + KeyOp op; }; -Rune keys[NKEYS] = { - [K↑] Kup, - [K←] Kleft, - [K→] Kright, - [Kfire] ' ', - [Khyper] 'h', - [Kquit] 'q' +Keymap kmap[] = { + {.key = Kup, .op = K↑}, + {.key = Kleft, .op = K↺}, + {.key = Kright, .op = K↻}, + {.key = 'w', .op = K↑}, + {.key = 'a', .op = K↺}, + {.key = 'd', .op = K↻}, + {.key = ' ', .op = Kfire}, + {.key = 'h', .op = Khyper}, + {.key = 'y', .op = Ksay}, + {.key = 'q', .op = Kquit} }; ulong kup, kdown; @@ -40,7 +41,8 @@ int debug; void kbdproc(void *) { - Rune r, *k; + Rune r; + Keymap *k; char buf[128], *s; int fd, n; @@ -74,16 +76,17 @@ kbdproc(void *) kdown = 0; while(*s){ s += chartorune(&r, s); - for(k = keys; k < keys+NKEYS; k++) - if(r == *k){ - kdown |= 1 << k-keys; + for(k = kmap; k < kmap+nelem(kmap); k++) + if(r == k->key){ + kdown |= 1 << k->op; break; } } kup = ~kdown; if(debug) - fprint(2, "kup\t%lub\nkdown\t%lub\n", kup, kdown); + fprint(2, "kup %.*lub\nkdown %.*lub\n", + sizeof(kup)*8, kup, sizeof(kdown)*8, kdown); } } -- cgit v1.2.3