Posts tagged games in racket
… having spent most of the first blog post on writing a small game engine to be able to handle the Asteroids game, in this post we’ll look at how to implement the actors to actually make the game playable.
… in which we look how we can implement the classic Asteroids game game using only the Racket language and its graphics facilities. We’ll implement a basic game engine, a basic physics engine and the game itself, and manage to do it in about 1000 lines of code.
The previous blog post introduced the Tetris game mechanics and made the game playable. In this blog post we’ll look at how to build an actual GUI application around the game mechanics: we’ll keep score, increase difficulty, peek at the next block and more. As we do that, we’ll explore some more interesting things you can do with the Racket pict library, and look at some of the GUI facilities available in Racket.
The pasteboard%
object is an editor of snip%
objects and it implements some features that make sense for an editor: for example, you can select multiple snips and drag them around with the mouse, and you can move selected snips using the keyboard, you can also add any kind of snip, not just chess pieces to the pasteboard. Since none of these features are useful or desirable for a chess board game we will look at how to disable them.
This is a continuation of the previous blog post, where the racket pasteboard%
features are explored by implementing a Chess Game Board. In this blog post we look at how to restrict piece movements to chess board squares, permit only valid moves and implement turn based game play.
The Racket GUI library provides an “editor toolkit” which can be used to implement programs that use an interactive graphical canvas where objects can be moved around with the mouse. This toolkit has good reference documentation, however this documentation can be somewhat overwhelming, and it is not always clear how to begin writing such interactive application, or how to achieve some basic functionality, so I wrote a tutorial on how to implement a chess board game in Racket using the pasteboard%
and snip%
classes which are part of the GUI library.