Skip to content

Commit

Permalink
各エリア名をラベル表示する
Browse files Browse the repository at this point in the history
フォントを追加
ブロック単位でテキスト表示するdraw_textを追加
Frameクラスでラベルを描画する
  • Loading branch information
zariganitosh authored and zariganitosh committed Apr 28, 2014
1 parent 12a4d38 commit 6c2ae93
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tetris.rb
Expand Up @@ -17,6 +17,7 @@
[ 0, 0, 255],
[255, 127, 0],
[255, 0, 255]]
FONT = Font.new("/Library/Fonts/Arial Bold.ttf", 24)



Expand Down Expand Up @@ -44,6 +45,10 @@ def draw_field(field)
end
end

def draw_text(str, col, row)
render_text(str, col * BLOCK_SIZE, row * BLOCK_SIZE, FONT, Color.new(0, 0, 0))
end

end

class Tetrimino
Expand Down Expand Up @@ -194,8 +199,11 @@ def update(sender)

@screen.fill(Color.new(255, 255, 255))
@screen.render_texture(@field_view, 1 * BLOCK_SIZE, 5 * BLOCK_SIZE)
@screen.draw_text("SCORE", 13, 5)
@screen.render_texture(@score_view, 13 * BLOCK_SIZE, 6 * BLOCK_SIZE)
@screen.draw_text("LINES", 13, 9)
@screen.render_texture(@lines_view, 13 * BLOCK_SIZE, 10 * BLOCK_SIZE)
@screen.draw_text("NEXT", 4, 1)
@screen.render_texture(@next_view , 1 * BLOCK_SIZE, 2 * BLOCK_SIZE)
end
end
Expand Down

0 comments on commit 6c2ae93

Please sign in to comment.