shithub: musw

Download patch

ref: 42ea627853d79a54ef956a831e2f8badff5bfdb8
parent: b545537c9a6c7d32976b863cbb14792980d31e3d
author: rodri <rgl@antares-labs.eu>
date: Sun Apr 9 18:14:26 EDT 2023

added a new pulsar animation for the star sprite.
wrote a little description for the manpage.
generalized the drawconnecting() procedure into a drawprogressing() one that takes an arbitrary, nul-terminated string as input.

binary files /dev/null b/assets/spr/pulsar.pic differ
--- a/musw.c
+++ b/musw.c
@@ -480,7 +480,7 @@
 }
 
 void
-drawconnecting(void)
+drawprogressing(char *s)
 {
 	static double t0;
 	static Point p = {100,300};
@@ -491,11 +491,11 @@
 		t0 = nanosec();
 
 	if(nanosec()-t0 >= 5e9){ /* every five seconds */
-		p = Pt(ntruerand(SCRW-2*100)+100,ntruerand(SCRH-100)+100);
+		p = Pt(ntruerand(SCRW-stringwidth(font, s)-3*font->width),ntruerand(SCRH-font->height));
 		t0 = nanosec();
 	}
 
-	np = string(screenb, addpt(screenb->r.min, p), display->white, ZP, font, "connecting");
+	np = string(screenb, addpt(screenb->r.min, p), display->white, ZP, font, s);
 
 	for(i = 1; i < 3+1; i++){
 		if(nanosec()-t0 > i*1e9)
@@ -518,9 +518,10 @@
 		intro->draw(intro, screenb, subpt(divpt(screenb->r.max, 2), divpt(intro->r.max, 2)));
 		break;
 	case GSConnecting:
-		drawconnecting();
+		drawprogressing("connecting");
 		break;
 	case GSMatching:
+		drawprogressing("waiting for players");
 		break;
 	case GSPlaying:
 		drawship(&universe->ships[0], screenb);
@@ -548,8 +549,6 @@
 		sysfatal("resize failed");
 	unlockdisplay(display);
 
-//	screenrf.p = Pt2(screen->r.min.x+Dx(screen->r)/2,screen->r.max.y-Dy(screen->r)/2,1);
-
 	/* ignore move events */
 	if(Dx(screen->r) != SCRW || Dy(screen->r) != SCRH){
 		fd = open("/dev/wctl", OWRITE);
@@ -660,7 +659,7 @@
 		sysfatal("readvmodel: %r");
 	universe->ships[0].mdl = needlemdl;
 	universe->ships[1].mdl = wedgemdl;
-	universe->star.spr = readsprite("assets/spr/earth.pic", ZP, Rect(0,0,32,32), 5, 20e3);
+	universe->star.spr = readsprite("assets/spr/pulsar.pic", ZP, Rect(0,0,64,64), 9, 50);
 
 	intro = readsprite("assets/spr/intro.pic", ZP, Rect(0,0,640,480), 1, 0);
 
--- a/musw.man
+++ b/musw.man
@@ -4,7 +4,7 @@
 .SH SYNOPSIS
 .B games/musw
 [
-.B -d
+.B -dg
 ]
 .I dialstring
 .br
@@ -17,6 +17,10 @@
 .I addr
 ]
 .SH DESCRIPTION
+.I Musw
+is a multi-user, on-line version of
+.IR Spacewar! ,
+the space dogfight simulation game developed by Steve Russell in the 1960s for the PDP-1.
 .SH EXAMPLE
 .SH SOURCE
 .B /sys/src/games/musw
--- a/muswd.c
+++ b/muswd.c
@@ -473,11 +473,11 @@
 	fmtinstall(L'Φ', Φfmt);
 	addr = "udp!*!112";
 	ARGBEGIN{
-	case 'a':
-		addr = EARGF(usage());
-		break;
 	case 'd':
 		debug++;
+		break;
+	case 'a':
+		addr = EARGF(usage());
 		break;
 	default:
 		usage();