-
Notifications
You must be signed in to change notification settings - Fork 1
Home
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 the high-quality version or the low-quality version.
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 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
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.
- Allow player to change background music.
- Create a menu to allow players to start a game or quit.
- Allow players to exit their current game.
- GET RSPEC TO WORK
- Refactor, refactor, refactor.
Retris is released under the MIT license.
gosu uses the FMOD library. See what they have to say about licensing.