Mercurial > repos > icfp2014
diff code/gameState.lm @ 46:d631e68a45d5
separated out grid functions for reuse inside gameState.lm
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Sun, 27 Jul 2014 01:36:39 -0700 |
parents | 75f808e60aa8 |
children | 115695e42307 |
line wrap: on
line diff
--- a/code/gameState.lm Sat Jul 26 23:30:55 2014 -0700 +++ b/code/gameState.lm Sun Jul 27 01:36:39 2014 -0700 @@ -8,6 +8,26 @@ filter flatten ] from: (module: "ll.lm") + + import: [ + makeTree:size + makeTree + get:fromTree:size + get:fromTree + treeMap:size + treeMap + tree:size:update:with + tree:update:with + tree:set:to + ] from: (module: "tree.lm") + + import: [ + grid:get + grid:update:with + grid:set:to + grid:inBounds? + calcPos + ] from: (module: "grid.lm") myAnd <- :a b { // only ones and zeros @@ -15,6 +35,9 @@ } makeTicker <- :mapWidth mapHeight { + lives <- 3 + win <- 0 + pillCount <- 50 makeEventType <- :lagTick isMovement behavior{ print: 12 @@ -26,9 +49,9 @@ } endOfLives <- makeEventType: (127 * mapWidth * mapHeight * 160) 0 :tick gameState { + lives <- 0 777 print addEvents <- [] - // set lives to zero #[addEvents gameState] } @@ -40,8 +63,14 @@ fruit2Appears <- (127 * 400) fruit1Expires <- (127 * 280) fruit2Expires <- (127 * 280) - //moveLambdaMan <- 127 (eating, lamdamanId) - //moveGhost <- (ghostType, ghostId) + + getLambdaManChoice <- :{0} + moveLambdaMan <- makeEventType: 127 0 : tick { + move <- getLambdaManChoice: + if: move + } + (eating, lamdamanId) + moveGhost <- (ghostType, ghostId) frightModeDeactivate <- (127 * 20) */ @@ -84,13 +113,24 @@ print: 15 // 2.) actions res <- executeEvents: tick 0 events gameState + events <- res value gameState <- (res tail) value print: 16 // 3.) collide pills powerpills fruit - #[events gameState] + if: pillCount = 0 { + win <- 1 + #[[] gameState] + } else: { + if: lives = 0 { + #[[] gameState] + } else: { + #[events gameState] + } + } + } nextTick <- :events { @@ -114,7 +154,7 @@ ] print: 6 gameState <- #[0 0] - while: {tick < runUntil} do: { + while: {(tick < runUntil) and (not: (events empty?))} do: { print: 7 tick <- events nextTick print: 5