angryrabbit / gosu-tetris

Gosu implementation of classic Tetris

This URL has Read+Write access

gosu-tetris / square.rb
100644 31 lines (27 sloc) 0.542 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Square < Shape
  
  def initialize(window)
    super
    @poses = []
  end
  
  def draw
    case @direction
    when :north: render_north
    when :east: render_east
    when :south: render_south
    when :west: render_west
    end
  end
  
  def render_north
    [
      [ 0, 1, 0 ],
      [ 1, 1, 0 ],
      [ 1, 0, 0 ]
    ].each_with_index do |row, pos_y|
      row.each_with_index do |col, pos_x|
        if col == 1
          @block_image.draw(pos_x * block_size, pos_y * block_size, 0)
        end
      end
    end
  end
  
end