tetris: minor fixes

pull/2562/head
Alexander Medvednikov 2019-10-27 10:24:28 +03:00
parent efdadc3758
commit 6e0a789b6d
1 changed files with 11 additions and 5 deletions

View File

@ -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() {