hackage/4Blocks0.2

A tetris-like game (works with GHC 6.8.3 and Gtk2hs 0.9.13)

4Blocks is a tetris-like game implemented in Haskell and Gtk2hs for an AI project.

Some notes:

  • The game currently works only with GHC 6.8.3 due to its use of Gtk2hs 0.9.13.
  • I haven't tested with anything later but it is likely to fail due the fact that later versions of Gtk2hs have a different system of handling events.
  • To make this project compatible with later versions of GHC and Gtk2hs two changes are required:
    • Remove the function "permutations" which was copied from a later GHC base library
    • Alter key-event handling to the version used by later Gtk2hs: some functions (in CommandKeys.hs) were simply introduced in order to disallow some of the keys used in the game (namely rotation) to trigger continuously when a key is held pressed. I believe this kind of behaviour can be managed automatically with Gtk2hs' new event handling mechanism, however I haven't had time to recode accordingly myself.
  • I hope to write a patch for this in the near future.

To play:

  • [1] Starts a Game
  • [P] Pause/Resume Game
  • [Esc] Exit Game
  • [A]/[Left] Shift Left
  • [D]/[Right] Shift Right
  • [W]/[Up] Hard Drop
  • [S]/[Down] Soft Drop
  • [Q]/[,] Rotate Left
  • [E]/[.] Rotate Right

Some gameplay features to add in the future:

  • T-spin points
  • Wall-kick
  • Sounds!

Finally:

  • Feel free to criticize (constructively) my code as this has been my first real forray into Haskell.
  • Email me on drewcalleja@gmail.com :)
  • Enjoy!