changeset 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 8b6f6e2cbf38
children a482086958e1
files code/dotScanner.lm code/gameState.lm code/grid.lm
diffstat 3 files changed, 25 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/code/dotScanner.lm	Sun Jul 27 02:35:24 2014 -0700
+++ b/code/dotScanner.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")
--- 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
--- a/code/grid.lm	Sun Jul 27 02:35:24 2014 -0700
+++ b/code/grid.lm	Sun Jul 27 13:49:45 2014 -0700
@@ -39,11 +39,15 @@
 		grid: grid update: pos with: :el { val }
 	}
 
+	gridMaxY <- :grid {grid value}
+	gridMaxX <- :grid {(get: 0 fromTree: grid) value}
+	gridArea <- :grid {(grid gridMaxX) * (grid gridMaxY)}
+
 	grid:inBounds? <- :grid :pos {
 		x <- pos value
 		y <- pos tail
-		maxY <- grid value
-		maxX <- (get: 0 fromTree: grid) value
+		maxY <- (grid gridMaxY)
+		maxX <- (grid gridMaxX)
 		((x >= 0) + (y >= 0) + (x < maxX) + (y < maxY)) > 0
 	}