aboutsummaryrefslogtreecommitdiff
path: root/musw.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-07-29 20:03:15 +0000
committerrodri <rgl@antares-labs.eu>2021-07-29 20:03:15 +0000
commitb57dba67153279a84a16bba40ae007c8ae710056 (patch)
tree62ff359275ae3c70b16d341fabf59c4df1431137 /musw.c
parent3241d4b8c80f9424a3f725b5905def22916fc854 (diff)
downloadmusw-b57dba67153279a84a16bba40ae007c8ae710056.tar.gz
musw-b57dba67153279a84a16bba40ae007c8ae710056.tar.bz2
musw-b57dba67153279a84a16bba40ae007c8ae710056.zip
incorporated libgeometry into the project.
transitioned the integrator from scalar to vector-based. added a packing procedure for Point2. created the structure to model bullets.
Diffstat (limited to 'musw.c')
-rw-r--r--musw.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/musw.c b/musw.c
index fddec50..006884a 100644
--- a/musw.c
+++ b/musw.c
@@ -4,6 +4,7 @@
#include <draw.h>
#include <mouse.h>
#include <keyboard.h>
+#include "libgeometry/geometry.h"
#include "dat.h"
#include "fns.h"
@@ -31,7 +32,7 @@ ulong kup, kdown;
typedef struct Ball Ball;
struct Ball
{
- double x, v;
+ Point2 p, v;
};
Ball bouncer;
@@ -102,10 +103,10 @@ threadnetrecv(void *arg)
io = ioproc();
while((n = ioread(io, fd, buf, sizeof buf)) > 0){
- unpack(buf, n, "dd", &bouncer.x, &bouncer.v);
+ unpack(buf, n, "PP", &bouncer.p, &bouncer.v);
if(debug)
- fprint(2, "bouncer [%g %g]\n", bouncer.x, bouncer.v);
+ fprint(2, "bouncer %v %v\n", bouncer.p, bouncer.v);
}
closeioproc(io);
}
@@ -134,7 +135,7 @@ redraw(void)
lockdisplay(display);
draw(screen, screen->r, display->black, nil, ZP);
- fillellipse(screen, addpt(screen->r.min,Pt(Dx(screen->r)/2,Dy(screen->r)/2+bouncer.x)), 2, 2, display->white, ZP);
+ fillellipse(screen, addpt(screen->r.min,Pt(Dx(screen->r)/2,Dy(screen->r)/2+bouncer.p.y)), 2, 2, display->white, ZP);
flushimage(display, 1);
unlockdisplay(display);
@@ -153,6 +154,7 @@ resize(void)
sysfatal("resize failed");
unlockdisplay(display);
+ /* ignore move events */
if(Dx(screen->r) != SCRW || Dy(screen->r) != SCRH){
fd = open("/dev/wctl", OWRITE);
if(fd >= 0){
@@ -179,6 +181,7 @@ threadmain(int argc, char *argv[])
Mousectl *mc;
Ioproc *io;
+ GEOMfmtinstall();
ARGBEGIN{
case 'd':
debug++;