diff code/gameState.lm @ 50:57a4bddadd46

added new helper functions to grids. more bugfixes to gameState.lm which compiles.
author William Morgan <billjunk@mrgn.org>
date Sun, 27 Jul 2014 13:49:45 -0700
parents 115695e42307
children 70423511f49d
line wrap: on
line diff
--- a/code/gameState.lm	Sun Jul 27 02:35:24 2014 -0700
+++ b/code/gameState.lm	Sun Jul 27 13:49:45 2014 -0700
@@ -25,6 +25,9 @@
 		grid:get	
 		grid:update:with
 		grid:set:to
+		gridMaxX
+		gridMaxY
+		gridArea
 		grid:inBounds?
 		calcPos
 	] from: (module: "grid.lm")
@@ -34,7 +37,7 @@
 		(a + b) = 2
 	}
 
-	makeTicker <- :mapWidth mapHeight {
+	makeTicker <- :mapGrid {
 		lives <- 3
 		lambdamanPos <- #[5 5]
 		win <- 0
@@ -49,26 +52,25 @@
 			}
 		}
 
-		endOfLives <- makeEventType: (127 * mapWidth * mapHeight * 160) 0 :tick gameState {
+		endOfLives <- makeEventType: (127 * (mapGrid gridArea) * 16) 0 :tick gameState {
 			lives <- 0
 			777 print
 			addEvents <- []
 			#[addEvents gameState]
 		}
-
-		isFood <- :tile {(2 <= tile) and (tile <= 4)}
-		getLambdaManChoice <- :{0}
+		isFood <- :tile { (2 <= tile) myAnd: (tile <= 4) }
+		getLambdaManChoice <- {0}
 		moveLambdaMan <- makeEventType: 127 1 :tick gameState {
 			move <- getLambdaManChoice: 
 			newPos <- (calcPos: move lambdamanPos)
-			impending <- grid: grid get: newPos
+			impending <- grid: mapGrid get: newPos
 			if: (not: (impending = 0)) {
 				lambdamanPos <- impending
-			} else { }
+			} else: { }
 
 			if: (impending isFood) {
 				#[(moveLambdaMan: (tick + 10)) gameState]
-			} else { 
+			} else: { 
 				#[(moveLambdaMan: tick) gameState]
 			}
 		}
@@ -169,7 +171,7 @@
 			]
 			print: 6
 			gameState <- #[0 0]
-			while: {(tick < runUntil) and (not: (events empty?))} do: {
+			while: {(tick < runUntil) myAnd: (not: (events empty?))} do: {
 				print: 7
 				tick <- events nextTick
 				print: 5
@@ -183,7 +185,11 @@
 
 	step <- :myState world {
 		print: 1
-		ticker <- makeTicker: 10 10
+		grid <- makeTree: (map: (world value) :row { 
+			makeTree: row 
+		})
+
+		ticker <- makeTicker: grid
 		print: 2
 		ticker: 1000
 		print: 3