@@ -0,0 +1,83 @@
2+module GameSkeleton where
6+{-- Part 1: Model the user input ----------------------------------------------
8+What information do you need to represent all relevant user input?
10+Task: Redefine `UserInput` to include all of the information you need.
11+ Redifene `userInput` to be a signal that correctly models the user
12+ input as described by `UserInput`.
14+------------------------------------------------------------------------------}
16+data UserInput = UserInput
18+userInput = constant UserInput
20+data Input = Input Float UserInput
24+{-- Part 2: Model the game ----------------------------------------------------
26+What information do you need to represent the entire game?
28+Tasks: Redefine `GameState` to represent your particular game.
29+ Redefine `defaultGame` to represent your initial game state.
31+For example, if you want to represent many objects that just have a position,
32+your GameState might just be a list of coordinates and your default game might
33+be an empty list (no objects at the start):
35+ data GameState = GameState [(Float,Float)]
36+ defaultGame = GameState []
38+------------------------------------------------------------------------------}
40+data GameState = GameState
42+defaultGame = GameState
46+{-- Part 3: Update the game ---------------------------------------------------
48+How does the game step from one state to another based on user input?
50+Task: redefine `stepGame` to use the UserInput and GameState
51+ you defined in parts 1 and 2. Maybe use some helper functions
52+ to break up the work, stepping smaller parts of the game.
54+------------------------------------------------------------------------------}
56+stepGame (Input delta (UserInput)) (GameState) = GameState
60+{-- Part 4: Display the game --------------------------------------------------
62+How should the GameState be displayed to the user?
64+Task: redefine `display` to use the GameState you defined in part 2.
66+------------------------------------------------------------------------------}
68+display (w,h) gameState = asText gameState
72+{-- That's all folks! ---------------------------------------------------------
74+The following code puts it all together and show it on screen.
76+------------------------------------------------------------------------------}
79+input = sampleOn delta (lift2 Input delta userInput)
81+gameState = foldp stepGame defaultGame input
83+main = lift2 display Window.dimensions gameState