COSC 231 WINTER 2014 PP # 4 Putting out a fire Assigned: 20 February 2014 Due: 12 March 2014 ---> DO NOT USE HTML5 CANVAS FOR THIS PROJECT <--- Spec: When an html page is loaded, it has a randomly distributed terrain with woods (brown), water (blue), and brick (red). It also has our hero: a fireman. At random times, lightning will strike the terrain. If the lightning strikes wood, the wood at that cell catches on fire (color yellow). Only wood can burn. The wood will burn until the fireman puts it out. The fire will spread as time goes on. So, each cell of the terrain can be in one of 5 states indicated visually by color or by image: wood: brown water: blue brick: red fire: yellow burnt: black You will control the hero by moving him with arrow keys or with letters on the keyboard. When the hero steps on a cell, you display the hero (not the cell state). When the hero steps off a cell, the new state of the cell is displayed. The hero puts out a fire cell by stepping on it. After a fire cell has been stepped on, the cell is burnt. Hero caused cell state transition (when hero steps on a cell, then steps off it) wood --> wood fire --> burnt burnt --> burnt water --> NOT ALLOWED brick --> NOT ALLOWED Lightning caused cell state transition wood --> flash, then fire fire --> flash, then fire burnt --> flash, then burnt water --> flash, then water brick --> flash, then brick The hero should move only after you press a key. The hero CANNOT cross brick and CANNOT cross water. He can cross wood and burnt. Directions: arrow key , keyboard char arrow up, i arrow right, l arrow left, j arrow down, k Lightning should strike approximately every 5 seconds. Note! brick, water and burnt cells will not burn. Only wood burns. You should indicate that lightning strikes a cell, but quickly remove the lightning flash from the terrain. Terrain: Your program should build a random terrain. There will be *approximately*: wood 80%, water 15%, brick 5%. The game board (terrain) should occupy a 100 X 100 grid (or more, pick a size that makes for a nice game). The fire will progress by itself. Every 500 ms, the fire will grow to NEWS neighbors (that are burnable). The game board is bounded by the screen. Do not allow the hero to move off the board and do not allow fire or lightning off the board. If the user tries to move the hero off the board or over water or over brick, the hero stays in the original location. The hero *can* move over wood, fire, and burnt. The game will last for 30 seconds. The score is a two place value: (1) the number of seconds there is no fire (2) the number of fire cells the hero stamps out (i.e., the number of burnt cells) Turn in: Hard copy of code screen shot in the middle of the game screen shot at end of game (showing the score) Grade based on: Correctness Elegance & Readability: alignment, variable names, comments, etc. Extra credit for: tunable rate of burn tunable rate of lightning strikes different image of hero to indicate most recent direction of motion fixed terrain (i.e., not randomly constructed on page load -- you could e.g., select from a set of previously built terrains in increasing difficulty)