May 2, 2014
A game very similar to the popular game: Pong. Play against the computer's pseudo AI. Use the arrow keys to move your racket.
(This is a screen shot which shows the main screen of the game.)
How to play
- Use the up or down arrow keys to catch the ball with your racket.
- The game is over if you fail to catch the ball
- Press P to pause.
Here are the key concepts that were used in order to develop this game:
- Data abstraction. The elements of the game are defined, then are called using a simple identifier, for instance
(define BALL (circle 18 "solid" "red")).
- Conditionals and functions. Making the code modular and calling other functions depending on certain conditions.
- Lists. Keeping track of the ball's state.
The project makes use of two libraries and one algorithm that drives the game.
- The universe.rkt teachpack implements and provides the functionality for creating interactive, graphical programs that consist of plain mathematical functions.
- The image teachpack provides a number of basic image construction functions, along with combinators for building more complex images out of existing images. Basic images include various polygons, ellipses and circles, and text, as well as bitmaps.
- The algorithm is fairly generic, the computer always collides its paddle with the ball, by matching paddle's height with the ball's height.
I think one of the main innovations are efficiency. They code is very simple and clear to understand. It takes great advantage of the "bing bang" handler functions. A function which can combine other functions and make them run seamlessly.
How does it work?
The major components and their interaction with each other:
After the bing bang explosion, these function will be called to make the game work.
Thanks the the book: Realm of racket, I was able to make good use the the universe library. Realm of racket is a book that teaches you the fundamentals of game development using racket. The software is a work in progress, it still needs to be fined tuned. Possible implementations might include: score counter, restart option and sound.