Git Product home page Git Product logo

atoms-in-haskell's Introduction

Functional Programming Project

Concept:
The player controls the movement of a white pixel. The player has to
evade red pixels that spawn at an increasing rate at the top of the screen
and move with constant velocity over the screen while getting deflected at
the borders of the screen. If the player touches a red pixel, the game is over.
Red pixels eventually turn green. When the player collides with green pixels,
an explosion occurs that will destroy all the red and green pixels in a certain 
radius. The player is awarded with points for every destroyed pixel, using the
formula 

	points_awarded = (pixels_destroyed) ^ 2
	
After touching a red pixel, the total score is displayed and the player can start
a new round.


Player Interaction:
The player can move the white pixel using the WASD keys.
When displaying the score, the player can restart using SPACE.


How it works:
Every frame, the following procedure is executed:

IF not playing
	display score
ELSE
	handle input -> move white pixel
	update pixel positions & remaining time to turn green
	spawn new red pixel if needed
	detect collisions (set explosion, playing)
	IF explosion
		destroy pixels, update score
	display everything

	
A few technical details:
While the player has integer coordinates, all the other pixels have float coordinates.
The system has its origin in the top left corner, positive x is to the right, positive y
is down. The center of a display-pixel is (x.5, y.5) in the internal system, meaning that the 
white player-pixel on (x, y) is displayed on display coordinates (x, y) and red and 
green pixels are displayed on (floor x, floor y).
While the position in the top row and the movement vector of new pixels is selected pseudo-randomly
(using a Blum-Blum-Shub generator), the spawn is always in the half of the screen where the player is
currently not and the direction is away from the player in order to avoid instant hittings.

Notes for making:
Main.hs needs to be compiled with stack ghc using the command "stack ghc -- --make Main.hs"

atoms-in-haskell's People

Contributors

lubocode avatar

Watchers

Oliver S. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.