Skip to content
angryrabbit edited this page Sep 14, 2010 · 14 revisions

Welcome to the Retris wiki

Retris is a Tetris clone written in Ruby using the gosu library.

Retris is no longer under active development. I, the author, have moved onto other projects.

Watch a demo

Watch the high-quality version or the low-quality version.

State machine support

Retris supports a simple state machine mechanism.

To build your own states, extend StateMachine and implement any or all of the four primary gosu window methods: update, draw, button_down and button_up.

Retris expects an InitialState class to exist. Beyond that you can write as many states as you want. Or none, if you’re into lumping all your game logic into one object.

Shifting between states is a matter of assigning a new state object to the GameWindow’s state variable. Example:


class InitialState < StateMachine

  def some_method
    base.state = PlayingState.new(base)
  end

end

In the above case, base refers to the GameWindow instance.

The Audible module

The Audible module allows your objects to play Gosu::Sample objects in a easy, Rails/DSL-like manner. Example:


class Shape

  include Audible

  sample :name => :rotate, :filename => 'media/rotate.wav'

  def rotate
    play_sample(:rotate)
  end

end

Bugs

Line clearing

There seems to be an issue with clearing lines correctly. I don’t know how to recreate the problem, but it’s easily identified when, after a line clear operation, there is still an empty row on screen.

Update 2008.6.5

I think the line clearing fails when you have one or more consecutive complete lines followed by an incomplete line followed by another complete line. Interesting.

Rotation axis

This is more a design-flaw that a bug. The shapes rotate on their upper-left most definition instead of in an arbitrary block like the real Tetris game. While usually not a big deal, it does cause issues when trying to rotate, say, the straight-edge while close to a wall.

Loss condition

The loss condition is unforgiving and unrealistic. For example, when a straight edge appears on screen it is vertically oriented. If the player only has 4 blocks of available height, the straight edge will consume all of it. This results in an immediate loss. The correct behavior requires the player be given the standard “time to dock” delay before signaling a loss.

To-do

  1. Allow player to change background music.
  2. Create a menu to allow players to start a game or quit.
  3. Allow players to exit their current game.
  4. GET RSPEC TO WORK
  5. Refactor, refactor, refactor.

Legal

Retris is released under the MIT license.

gosu uses the FMOD library. See what they have to say about licensing.