shithub: riscv

Download patch

ref: 2c6c64c47487dbe8af6a6dc450b33931ec937601
parent: acd1a3eddabf29ed08b5a0504b379141ab0e4acf
author: spew <devnull@localhost>
date: Fri Mar 10 05:37:12 EST 2017

games/galaxy: simplify zoom loop

--- a/sys/src/games/galaxy/galaxy.c
+++ b/sys/src/games/galaxy/galaxy.c
@@ -356,33 +356,23 @@
 	double f, olds;
 
 	setcursor(mc, &zoomcursor);
+
+	z = mc->xy;
+	olds = scale;
 	for(;;) {
-		for(;;) {
-			readmouse(mc);
-			if(mc->buttons == 0)
-				continue;
-			if(mc->buttons != 2)
-				goto End;
+		readmouse(mc);
+		if(mc->buttons != 2)
 			break;
-		}
-		z = mc->xy;
-		olds = scale;
+		d = subpt(mc->xy, z);
+		f = tanh((double)d.y/200) + 1;
 		pause(0, 0);
-		for(;;) {
-			readmouse(mc);
-			if(mc->buttons != 2)
-				break;
-			drawglxy();
-			line(screen, z, (Point){z.x, mc->xy.y}, Enddisc, Enddisc, 0, display->white, ZP);
-			d = subpt(mc->xy, z);
-			f = tanh((double)d.y/200) + 1;
-			scale = f*olds;
-		}
+		scale = f*olds;
+		drawglxy();
 		pause(1, 0);
 	}
 
-End:
 	setcursor(mc, cursor);
+	pause(1, 0);
 }
 
 void