/UU-INFOFP-Game

Game in haskell, for a school project.

Primary LanguageHaskell

UU-INFOFP-Game

Download the latest stable version from the releases page, or browse all build artifacts.

Setup development environment (Debian & friends)

# Install dependencies
sudo apt-get install freeglut3 libsdl2-ttf-dev

# Setup stack
stack setup

# Build and run the game
stack run

# Automatically build game when source changes
stack build --file-watch

Setup development environment (Windows)

# Install dependencies
stack exec -- pacman -Syu
stack exec -- pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_ttf
# Download and place them next to UU-INFOFP-Game-exe.exe
# - https://www.libsdl.org/release/SDL2-devel-2.0.16-mingw.tar.gz
# - https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-mingw.tar.gz

# Setup stack
stack setup

# Build and run the game
stack run

# Automatically build game when source changes
stack build --file-watch

Optional stuff

# Install hlint
stack install hlint

# Install stuff needed for debugging
stack install haskell-dap ghci-dap haskell-debug-adapter

# Show FPS counter in console
LIBGL_SHOW_FPS=1 stack exec UU-INFOFP-Game-exe

# Profile the game performance
# Make sure to exit the game from the main menu by navigating to Quit. Exiting from the console, or by closing the window does NOT work.
stack --profile run --rts-options -p

Screenshots

This is an image

How to run a benchmark (Linux only)

# Create dist
./scripts/build-dist.sh

# Go into dist folder and run benchmark
cd dist
python3 run-benchmark.py

How to use the map builder

Setup

Install the Tiled software.

Note: map and level are used interchangeably throughout this document. They mean the same thing.

How to create a level

Open the Tiled Map Editor and click on "New" -> "New Map". Pick the following settings and then save your map in the design\tiled folder as YourMapName.tmx.

Orientation: Orthogonal
Tile layer format: CSV
Tile render order: Right Down

Map Size: Fixed
Width: 72 tiles
Height: 42 tiles
Width/Height: 8 px

Next you should click on "Map" -> "Map Properties" and add the Name property. Here you can enter the display name of your map. To export your level click "File" -> "Export As" and save it as a YourMapName.xml file inside the assets/levels folder.

Level Specification

A level consists of zero or more tile layers, and at most one object layer. The tile layers should be named Foreground or Background to show up in the game. Tile layers with another name will not be rendered. The name of the object layer does not matter. See the (Level Objects)[] section for more info about the objects.

Map Properties

Properties are case sensitive and optional, unless noted otherwise.

  • Name: Level name, required!
  • Foreground: Level foreground image, should be the name of a file inside the assets/images directory (without the file extension).
  • Background: Level background image, same rules as above.

Level Objects

Player spawn Object

  • Name: PlayerSpawn
  • Behavior: The player will spawn at its location.

Collision Object

  • Name: Collision
  • Behavior: The player and the enemies collide with this object.

Enemy Collision Object

  • Name: EnemyCollision
  • Behavior: Only enemies collide with this object.

Damage Object

  • Name: Damage
  • Behavior: The player will get a set amount of damage each tick when they touch this object.

Death Object

  • Name: Death
  • Behavior: The player will die when they touch this object.

Enemy Spawner Object

  • Name: EnemySpawner
  • Properties:
    • Type: Enemy type. Possible values: Crab | Sun.
    • Chance: Number "0" to "100" (as a string) how likely it is an enemy will spawn. An enemy will spawn at least once regardless of this value.
  • Behavior: Will spawn an enemy once at the level start, and based on chance every second.

Credits