Skip to content

Commit

Permalink
ブロックで満たされた段をクリアする
Browse files Browse the repository at this point in the history
  • Loading branch information
zariganitosh authored and zariganitosh committed Apr 23, 2014
1 parent b2f2064 commit 7aff84e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tetris.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ def import(tetrimino)
end
end
end

def clear_lines
@matrix.reject!{|row| !row.include?(nil)}
deleted_line = FIELD_ROW - @matrix.size
deleted_line.times{@matrix.unshift(Array.new(10){nil})}
end

end


Expand All @@ -160,6 +167,7 @@ def import(tetrimino)

if @tetrimino.state == :dead then
@field.import(@tetrimino)
@field.clear_lines
@tetrimino = nil
end

Expand Down

0 comments on commit 7aff84e

Please sign in to comment.