Giter VIP home page Giter VIP logo

pong's Introduction

Pong

A simple pong game implemented in Haskell, using the Gloss library, and SDL2 for sounds and music.

Sample Game

Building Pong

Pong was built using the command-line tool cabal, also known as cabal-install. If you do not already have this installed, find out how to do so at Haskell.org, under the section titled Minimal installers.

For example, on openSUSE, this was as easy as:

sudo zypper install ghc cabal-install
cabal update

Once you have the GHC compiler and cabal installed on your system, you can build Pong.

I highly recommend using a Cabal sandbox for building this project. After you have cloned the repo with:

git clone https://github.com/htoigo/pong.git

move into the newly-created pong directory with cd pong, then create a new sandbox:

cabal sandbox init

Now, install the required dependencies into the new sandbox (which will be isolated from any system-wide Haskell installation), and build Pong:

cabal install --only-dependencies
cabal build

You are now ready to play Pong!

Usage

Start a game of Pong by invoking:

cabal run pong

from the Pong directory. Press '1' to begin a single-player game, and press '2' to begin a two-player game. The left-hand player uses the 'w' and 's' keys to move her paddle up and down, while the right-hand player uses the up and down arrow keys. The full list of keys used is:

'1'      begin a single-player game
'2'      begin a 2-player game
'w'      move left paddle up
's'      "              " down
UP       move right paddle up
DOWN     "               " down
SPACE    pause/unpause the game
ESC      abort the game, closing the window
'r'      reset the game after it has ended

Contributing

Rather than contributing here, I think it would be a great idea for you to work through Andrew Gibiansky's excellent tutorial for yourself, which was how this project started for me. (See the Credits section, below.)

Credits

This little Haskell game grew out of my working through the excellent tutorial blog post "Your First Haskell Application (with Gloss)" by Andrew Gibiansky, used under CC BY-SA. It really is a great resource for learning to build a Haskell application using Cabal. Thanks, Andrew! For someone with some experience programming in Haskell, but who has never before built a Cabal application, the included code gives you a solid foundation from which to build, and the exercises, especially, are meaty with just the right level of challenge to get you thoroughly engrossed. Go check it out!

License

New code contributions are licensed under the GNU General Public License version 3. New content is licensed under CC BY-SA. See the LICENSE file for details.

pong's People

Contributors

htoigo avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.