by Christina Zeller
- This document gives an unsorted overview of suggested tasks in Haskell game programming.
- The unsorted tasks vary in complexity. Don't get (too) frustrated but ask me for hints.
Table of Contents:
- Hands on tasks (playing with the code)
- Hands on tasks (createing a board game)
- Exploring the game structure
- Haskanoid: SDL FRP (Yampa) Wiimote
- Confused?
Hands on tasks (playing with the code)
- Change the title of the window.
- Change the default screen size.
- Change the screen margin.
- Change the background colour.
- Change the fields colour.
- Change the number of fields of a grid.
- Change the shape of the grid.
- Add a new level.
- Add a level solved definition for each level.
- Add a maximal number of moves in a level.
- Add a field to count moves.
- Add a pause game state.
- Do not render/display empty fields.
- Do render/display empty fields as small filled pies or ellipses.
- Draw fields as triangles.
- Add rendering/displaying of a level solved status.
- Add rendering/displaying of a paused game status.
- Add a button (rectangle, circle, ...) next to the game board.
- Add the level number next to the game board.
- Render images/assets instead of circles/triangles/rectangles (one source of free assets).
- Add audio.
- Close the window if the close button of a window was clicked.
- Handle/Store a keyboard pressed key 'P' event.
- Add a function to check whether the background was clicked.
- Add a function to check whether a specific area was clicked (e.g., a restart button).
- Add a new field kind.
- Change the allowed moves.
- Change the result of a move.
- Count the number of moves.
- Restart the level if the background or a button on the screen was clicked.
- Add a level solved behaviour.
- Add a pause game behaviour.
- React on a keyboard pressed key 'P' event with changing to the paused game status.
- Reimplement an existing board game (4 in a line, solitaire, find the pairs, Mensch "argere dich nicht, ...).
- Create your own board game (maybe using the board game scaffold) with your own logic and rules.
- Create the haddock documentation (see README) and get an overview of the game.
- Where do you expect:
- The handling of mouse and key board events?
- The definition of the game board and its elements in general?
- The definition of a solved game board?
- The handling of the game flow?
- The rendering of a game board?
- The background colour?
- The colour of fields of the board?
- The logical board size?
- The board size used for rendering?
- The definition of a valid move?
- The result of a move?
- The detection of clicked fields?
- Read about our basic game structure. Why you should read it? The document will tell you.
- Take a look at the following import examples. Can you associate them with the specific modules of the game?
- Example 1:
-- External imports
import Control.Monad (void)
import Data.Int (Int16, Int32)
import Data.List (transpose)
import qualified Data.Text as T (pack)
import Foreign.C.Types (CInt (CInt))
import SDL (InitFlag (InitVideo), Renderer, V2 (V2),
V4 (V4), Window, createSoftwareRenderer,
createWindow, defaultWindow, getWindowSurface,
getWindowSurface, initialize, showWindow,
surfaceFillRect, updateWindowSurface,
windowInitialSize)
import SDL.Primitive (fillCircle)
-- Internal imports
import Constants (Color, caption, defaultBG, screenMarginWH, screenWH)
import GameState (GameState, GameStatus (LevelPlaying), gameGrid, gameInfo,
gameLevel, gameStatus)
import Levels (LevelSpec, background, fieldColor, levels)
import Objects (Field, Grid, fieldId, findPosition)
- Example 2:
-- External imports
-- Internal imports
import GameState (GameState, GameStatus (LevelPlaying), gameGrid,
gameInfo, gameStatus)
import InputOutputMatch (clickedFields)
import Objects (Field, FieldKind (Empty, Tile), Grid, fieldKind,
swapFields)
import UserInput (Controller, controllerDragPoss)
- Example 3:
-- External imports
import Data.Ix (inRange)
-- Internal imports
import DeviceOutput (absFieldsPositions, calcFieldSize)
import Objects (Field, Grid)
- Example 4:
-- External imports
import Data.Ix (inRange)
import Data.List (find)
-- Internal imports
import DeviceOutput (ScreenPosition, gridFieldSize, gridFieldsAbsPositions)
import Objects (Field, Grid)
- Example 5:
-- External imports
-- Internal imports
import DeviceOutput (RenderingCtx, initializeGUI, render)
import GameLogic (gameLogic)
import GameState (GameState, defaultState)
import UserInput (Controller, defaultController, updateController)
- Example 6:
-- External imports
import Data.Int (Int32)
import SDL (EventPayload (MouseButtonEvent, MouseMotionEvent),
InputMotion (Pressed, Released), Point (P), V2 (V2),
eventPayload, mouseButtonEventMotion, mouseMotionEventPos,
pollEvent)
-- Internal imports
- Create a list for commonly used variables and abbreviations in the code. If you see irregularities you are very welcome to fix them.
- What makes it easy or hard to understand the code? If you want try to fix it and/or give us feedback regarding the difficulty of understanding our documents and our code.
- Compare the board game scaffold with the game structure of haskanoid and/or Pang a Lambda.
- Structure raindrops using our basic game structure.
- Take a look at the issues that we added and tagged with ZuriHac2018 of haskanoid our breakout game in Haskell. It uses functional reactive programming, can be played with various input devices (mouse, wiimote, ...) and can be compiled with SDL1 or SDL2.
Don't panic! Let's talk and find a solution. ;-)