aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/spr/earth.picbin0 -> 1931 bytes
-rw-r--r--dat.h2
-rw-r--r--fns.h7
-rw-r--r--mkfile2
-rw-r--r--musw.c13
5 files changed, 21 insertions, 3 deletions
diff --git a/assets/spr/earth.pic b/assets/spr/earth.pic
new file mode 100644
index 0000000..75d735b
--- /dev/null
+++ b/assets/spr/earth.pic
Binary files differ
diff --git a/dat.h b/dat.h
index 9435dcd..823a94a 100644
--- a/dat.h
+++ b/dat.h
@@ -93,7 +93,7 @@ struct Ship
struct Star
{
Particle;
- Sprite spr;
+ Sprite *spr;
};
struct Universe
diff --git a/fns.h b/fns.h
index f7276e8..59b80e8 100644
--- a/fns.h
+++ b/fns.h
@@ -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*);
diff --git a/mkfile b/mkfile
index 294137e..fb747b3 100644
--- a/mkfile
+++ b/mkfile
@@ -13,8 +13,8 @@ OFILES=\
pack.$O\
lobby.$O\
party.$O\
- sprite.$O\
universe.$O\
+ sprite.$O\
HFILES=\
dat.h\
diff --git a/musw.c b/musw.c
index 84bf4b9..330695d 100644
--- a/musw.c
+++ b/musw.c
@@ -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));
}
}