Skip to content

geffk2/TheHorrorOfHaskell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TheHorrorOfHaskell

Haskell

Links

Introduction

Click here Boo

Project description

In this project we want to create a raytraced horror game like slenderman. Player will need to find some items on the map, while being chased by scary thing. Images to understand idea that we want to implement.

This project seems interesting to us because it contains a lot of stept:

  • Raytracing
  • Map designing
  • NPC with some pseudo AI (as horror character)

We have exactly 3 team members, so we descided to distribute our roles like this:

  • Ekaterina Maximova - responsible for raytracing and testing (because other members are too scared to test)
  • Polina Zelenskaya - responsible for map, charachers and sounds designing
  • Danila Kuzmin - responsible for NPC AI

Raytracing

We have seen that CodeWorld already have example of game raytracing. We want to try to implement more effective and complex type to render not only blocks, but more complex elements.

CodeWorldRaytracing

Characher and map designing

It is important to understand how to render complex objects and how to make game lightweighted, but with good graphics. Also due to the fact that game should be horror, it is essential to try to create horror atmosphere. Like characters below are not scary at all.

Non horror character example

NPC AI

One of the most important part in horror games is NPC logic. NPC should pursue, but not always. NPC should scare, but not always. And so on. So NPC logic is complex thing that make most of the game. Good example of NPC logic is in one video that I am struggling to find, however key points are that:

  • There is no NPC (only scary sounds) till player find something
  • NPC walking randomly till player achieve something
  • Then NPC is chasing player

That's one example and how it will be implemented will be discussed with team

Game images

We inpired by the game slenderman.

SlendermanImage1 SlendermanImage2

Installation

Requirements

Before installing anything below, Linux users should download sound libraries and rebuild SDL if you have already installed one

$ sudo apt-get install libasound2-dev libpulse-dev

This game is written on Haskell, so you should download gch, cabal, sdl2, sdl2-mixer.

ghc-8.10.7
cabal-3.6
sdl2-2.0.22
sdl2_mixer-2.0.4

Run game

Type in shell:

$ cabal run thehorrorofhaskell

to launch the game

or

$ cabal run mapeditor

to launch the map editor

If window boo appeared, you succesfully finished your configuration!

Gameplay

Game story

Your goal is to find all buttons to escape from old creppy house. However there you are not alone in the house, something strange is also with you. But don't mind it, e̷v̴e̴r̶y̸t̴h̵i̸n̸g̴ ̴w̷i̴l̶l̶ ̴b̴e̴ ̵a̶l̵r̴i̷g̶h̸t̸.

Controls

This game require only keyboard, so here is the list of all buttons and their functionallity: Game:

  • w - move forwars
  • a - turn left
  • s - move backeards
  • d - turn right
  • f - press button

Map editor:

  • w - move view upwards
  • s - move view downwards
  • a - move view left
  • d - move view right
  • i - move pointer upwards
  • k - move pointer downwards
  • j - move pointer left
  • l - move pointer right
  • h - place tile
  • q - previous tile
  • e - next tile
  • shift + s - save to file

Important to mention that all buttons are key and language sensitive!

Development

Raycasting implementation

For walls we used Graphics.Gloss.Algorithms.RayCast.castSegIntoCellularQuadTree which is already build-in tool to detect where 'ray' intersected with object (Coords, Tile, Side). For more info check documentation.

For textures we implemeted hitToTexture function which by hitPoint and Side draw texture. Implementation could be found here.

For fog we used idea the further the block, the darker it should be, and based on this we just make render-line darker depending on distance/renderDistance.

Sprites was the main difficulty. As they could be rendered by pixels, which makes game laggy and unplayable. So we descided to consider different approach where we sort all render objects by distance (0 - the furtheres) and then render them in this order (so further objects will be rendered behind nearest). This provides us abillity to draw sprites with no lag but small disproportion.

NPC algorithm implementation

Game difficulty rises with each button press. The more buttons you press, the harder is becames for you to escape NPC.

NPC brain is BFS algorithm, so it know where exatly you are and what is the best way to get to you.

Spoiler: gameplay mechanics

Difficulty modes (speed in blocks/second):

  • 0-1 buttons pressed - NPC is not moving
  • 2 buttons pressed - NPC speed 0.5
  • 3 buttons pressed - NPC speed 1.2
  • 4 buttons pressed - NPC speed 1.7

P.S. Player speed is 2
P.P.S You could win in this game, we checked (it was very scary).

Sounds & Music

We used sdl2-mixer as main music library. However we faced the problem that with walking (or any other long sound) we run out of channels instantly. So we descided to have each sound on their own channel and manage them individually. This provides us to play all sounds at the same time as well as not to start the same sound on different channels simultaneously.

Releases

No releases published

Packages

No packages published