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 | |
parent | 75dfc00c40c6d811143b3dfaca865e3caa48db68 (diff) | |
download | musw-8731378bba72cf2a5084f90fb375c998f2be6472.tar.gz musw-8731378bba72cf2a5084f90fb375c998f2be6472.tar.bz2 musw-8731378bba72cf2a5084f90fb375c998f2be6472.zip |
added an sprite for the Earth.
-rw-r--r-- | assets/spr/earth.pic | bin | 0 -> 1931 bytes | |||
-rw-r--r-- | dat.h | 2 | ||||
-rw-r--r-- | fns.h | 7 | ||||
-rw-r--r-- | mkfile | 2 | ||||
-rw-r--r-- | musw.c | 13 |
5 files changed, 21 insertions, 3 deletions
diff --git a/assets/spr/earth.pic b/assets/spr/earth.pic Binary files differnew file mode 100644 index 0000000..75d735b --- /dev/null +++ b/assets/spr/earth.pic @@ -93,7 +93,7 @@ struct Ship struct Star { Particle; - Sprite spr; + Sprite *spr; }; struct Universe @@ -43,3 +43,10 @@ void addparty(Party*); Universe *newuniverse(void); void deluniverse(Universe*); void inituniverse(Universe*); + +/* + * sprite + */ +Sprite *newsprite(Image*, Point, Rectangle, int, ulong); +Sprite *readsprite(char*, Point, Rectangle, int, ulong); +void delsprite(Sprite*); @@ -13,8 +13,8 @@ OFILES=\ pack.$O\ lobby.$O\ party.$O\ - sprite.$O\ universe.$O\ + sprite.$O\ HFILES=\ dat.h\ @@ -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)); } } |