From 00b8d7005e233bafced3467174e95cf6edb6eec1 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Fri, 7 Nov 2014 08:51:18 -0800 Subject: First flesh out of Semantic Differences --- examples/demos/src/main/scala/canvasapp/FlappyLine.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/demos/src/main/scala/canvasapp/FlappyLine.scala b/examples/demos/src/main/scala/canvasapp/FlappyLine.scala index 50c9906..57a1f2e 100644 --- a/examples/demos/src/main/scala/canvasapp/FlappyLine.scala +++ b/examples/demos/src/main/scala/canvasapp/FlappyLine.scala @@ -60,11 +60,15 @@ object FlappyLine extends{ // Render obstacles, and check for collision renderer.fillStyle = "darkblue" for((holeY, i) <- obstacles.zipWithIndex){ + // Where each obstacle appears depends on what frame it is. + // This is what keeps the obstacles moving to the left as time passes. val holeX = i * obstacleGap - frame + canvas.width renderer.fillRect(holeX, 0, 5, holeY - holeSize) renderer.fillRect( holeX, holeY + holeSize, 5, canvas.height - holeY - holeSize ) + + // Kill the player if he hits some obstacle if (math.abs(holeX - canvas.width/2) < 5 && math.abs(holeY - playerY) > holeSize){ dead = 50 @@ -81,7 +85,6 @@ object FlappyLine extends{ } } - def runDead() = { playerY = canvas.height / 2 playerV = 0 -- cgit v1.2.3