From 933b15bd5a8e9383804df62b59d3f6092c151750 Mon Sep 17 00:00:00 2001 From: Nathan Hamblen Date: Mon, 5 Apr 2010 08:40:36 -0400 Subject: [PATCH] axis with while loop --- Continue/Continue.spde | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/Continue/Continue.spde b/Continue/Continue.spde index 6929abd..bdfac98 100644 --- a/Continue/Continue.spde +++ b/Continue/Continue.spde @@ -3,29 +3,26 @@ import scala.util.continuations._ size(600, 400) frameRate(15) -def go(p: Point) = shift { k: (Point => Point) => - k(p) -} -def up = go(Point(0, -1)) -def down = go(Point(0, 1)) -def left = go(Point(-1, 0)) -def right = go(Point(1, 0)) -def pass = go(Point(0, 0)) - -var position = Point(width/2, height/2) - case class Point(x: Int, y: Int) { def + (p:Point) = Point(x + p.x, y + p.y) } -def draw() { - position = reset { - (keyCode match { - case DOWN => down - case RIGHT => right - case _ => pass - } ) + go(position) +var cur: Unit => Unit = { (u: Unit) => + reset { + var x = 0 + while(true) { + x = (x + 1) % width + background(255) + color(0) + line(width - x, 0, x, height) + shift { k: (Unit => Unit) => + cur = k + } + } + () } - color(0) - point(position.x, position.y) +} + +def draw() { + cur() } \ No newline at end of file