From 6e0a789b6d357b5ab9f9961a28ecd9218a40778d Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 27 Oct 2019 10:24:28 +0300 Subject: [PATCH] tetris: minor fixes --- examples/tetris/tetris.v | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/tetris/tetris.v b/examples/tetris/tetris.v index aa0c698e3f..c9de22e3de 100644 --- a/examples/tetris/tetris.v +++ b/examples/tetris/tetris.v @@ -30,6 +30,11 @@ const ( size:TextSize color:gx.rgb(0, 0, 0) } + over_cfg = gx.TextCfg{ + align:gx.ALIGN_LEFT + size:TextSize + color:gx.White + } ) const ( @@ -308,8 +313,9 @@ fn (g &Game) draw_tetro() { } fn (g &Game) draw_block(i, j, color_idx int) { + color := if g.state == .gameover { gx.Gray } else { Colors[color_idx] } g.gg.draw_rect((j - 1) * BlockSize, (i - 1) * BlockSize, - BlockSize - 1, BlockSize - 1, Colors[color_idx]) + BlockSize - 1, BlockSize - 1, color) } fn (g &Game) draw_field() { @@ -325,12 +331,12 @@ fn (g &Game) draw_field() { fn (g mut Game) draw_ui() { if g.font_loaded { - g.ft.draw_text(1, 2, 'score: ' + g.score.str(), text_cfg) + g.ft.draw_text(1, 3, g.score.str(), text_cfg) if g.state == .gameover { g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth, 5 * TextSize, UIColor) - g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Over', text_cfg) - g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'SPACE to restart', text_cfg) + g.ft.draw_text(1, WinHeight / 2 + 0 * TextSize, 'Game Over', over_cfg) + g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'Space to restart', over_cfg) } else if g.state == .paused { g.gg.draw_rect(0, WinHeight / 2 - TextSize, WinWidth, 5 * TextSize, UIColor) @@ -338,7 +344,7 @@ fn (g mut Game) draw_ui() { g.ft.draw_text(1, WinHeight / 2 + 2 * TextSize, 'SPACE to resume', text_cfg) } } - g.gg.draw_rect(0, BlockSize, WinWidth, LimitThickness, UIColor) + //g.gg.draw_rect(0, BlockSize, WinWidth, LimitThickness, UIColor) } fn (g mut Game) draw_scene() {