Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
axis with while loop
  • Loading branch information
Nathan Hamblen committed Apr 5, 2010
1 parent cffd069 commit 933b15b
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions Continue/Continue.spde
Expand Up @@ -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()
}

0 comments on commit 933b15b

Please sign in to comment.