From 6c2ae93a5e891d911c5e4135cfdd9c0311b258c1 Mon Sep 17 00:00:00 2001 From: zariganitosh Date: Mon, 28 Apr 2014 15:05:35 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=84=E3=82=A8=E3=83=AA=E3=82=A2=E5=90=8D?= =?UTF-8?q?=E3=82=92=E3=83=A9=E3=83=99=E3=83=AB=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit フォントを追加 ブロック単位でテキスト表示するdraw_textを追加 Frameクラスでラベルを描画する --- tetris.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tetris.rb b/tetris.rb index 27d8b8d..49c6c14 100644 --- a/tetris.rb +++ b/tetris.rb @@ -17,6 +17,7 @@ [ 0, 0, 255], [255, 127, 0], [255, 0, 255]] +FONT = Font.new("/Library/Fonts/Arial Bold.ttf", 24) @@ -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 @@ -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