diff options
-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)); } } |