Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/soupi/sdl2-snake
An example application for sdl2.
https://github.com/soupi/sdl2-snake
example game haskell sdl2 snake
Last synced: about 2 months ago
JSON representation
An example application for sdl2.
- Host: GitHub
- URL: https://github.com/soupi/sdl2-snake
- Owner: soupi
- License: bsd-3-clause
- Created: 2018-05-19T13:23:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-19T09:11:20.000Z (almost 3 years ago)
- Last Synced: 2024-08-02T13:32:44.750Z (5 months ago)
- Topics: example, game, haskell, sdl2, snake
- Language: Haskell
- Homepage:
- Size: 132 KB
- Stars: 26
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Snake
This is an example application for [sdl2](https://hackage.haskell.org/package/sdl2).
Click on the SDL module in the link for a tutorial on how to get started with sdl2.
## Gameplay
![Gameplay gif](gameplay.gif)
## Build and Run
### Prerequisites
You will need to install [Stack](https://haskellstack.org).
You will also need sdl2 libraries:
> Note: You don't have to install ttf, image and mixer for this snake game to work, but you might want to use fonts, images and sounds later.
#### Ubuntu
```sh
sudo apt install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
```#### OS X
```sh
brew install sdl2 sdl2_ttf sdl2_image sdl2_mixer
```#### Windows
```sh
stack exec -- pacman -Syu
stack exec -- pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2 mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer
```### Build and Run
#### Stack
```sh
stack build && stack exec app
```## Want to tinker with this game? Here are a few ideas
- Do nothing when the user tries to move to the direction the snake is coming from instead of failing
- Change the snake's speed
- Add a key to restart the game
- Keep score and report to the user
- Add obstacles
- Play a sound when the snake eats the apple
- Report game over to the game window instead of to the console