diff options
author | rodri <rgl@antares-labs.eu> | 2021-08-01 16:39:55 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2021-08-01 16:39:55 +0000 |
commit | 8731378bba72cf2a5084f90fb375c998f2be6472 (patch) | |
tree | 605bb581fb0d31ffdeb4cb84ef078f53a981602d /musw.c | |
parent | 75dfc00c40c6d811143b3dfaca865e3caa48db68 (diff) | |
download | musw-8731378bba72cf2a5084f90fb375c998f2be6472.tar.gz musw-8731378bba72cf2a5084f90fb375c998f2be6472.tar.bz2 musw-8731378bba72cf2a5084f90fb375c998f2be6472.zip |
added an sprite for the Earth.
Diffstat (limited to 'musw.c')
-rw-r--r-- | musw.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -244,7 +244,7 @@ redraw(void) drawship(&universe->ships[0], screen); drawship(&universe->ships[1], screen); - fillellipse(screen, toscreen(universe->star.p), 4, 4, display->white, ZP); + universe->star.spr->draw(universe->star.spr, screen, subpt(toscreen(universe->star.p), Pt(16,16))); flushimage(display, 1); unlockdisplay(display); @@ -287,6 +287,8 @@ usage(void) void threadmain(int argc, char *argv[]) { + uvlong then, now; + double frametime; char *server; int fd; Mousectl *mc; @@ -330,13 +332,22 @@ threadmain(int argc, char *argv[]) sysfatal("readvmodel: %r"); universe->ships[0].mdl = needlemdl; universe->ships[1].mdl = needlemdl; + universe->star.spr = readsprite("assets/spr/earth.pic", ZP, Rect(0,0,32,32), 5, 20e3); threadcreate(threadnetrecv, &fd, 4096); threadcreate(threadresize, mc, 4096); + then = nanosec(); io = ioproc(); for(;;){ + now = nanosec(); + frametime = now - then; + then = now; + + universe->star.spr->step(universe->star.spr, frametime/1e6); + redraw(); + iosleep(io, HZ2MS(30)); } } |