examples: make tetris compile
parent
138d730dfa
commit
ad8ed851d0
|
@ -199,7 +199,7 @@ fn main() {
|
|||
|
||||
fn (mut g Game) init_game() {
|
||||
g.parse_tetros()
|
||||
rand.seed(time.now().unix)
|
||||
rand.seed(int(time.now().unix))
|
||||
g.generate_tetro()
|
||||
g.field = [] // TODO: g.field = [][]int
|
||||
// Generate the field, fill it with 0's, add -1's on each edge
|
||||
|
@ -341,8 +341,8 @@ 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) * block_size, (i - 1) * block_size,
|
||||
block_size - 1, block_size - 1, color)
|
||||
g.gg.draw_rect(f32((j - 1) * block_size), f32((i - 1) * block_size),
|
||||
f32(block_size - 1), f32(block_size - 1), color)
|
||||
}
|
||||
|
||||
fn (g &Game) draw_field() {
|
||||
|
|
|
@ -108,7 +108,8 @@ pub fn new_context(cfg Config) &GG {
|
|||
width: cfg.width
|
||||
height: cfg.height
|
||||
window: window
|
||||
clear_pass: gfx.create_clear_pass( f64(cfg.bg_color.r) / 255.0, f64(cfg.bg_color.g) / 255.0, f64(cfg.bg_color.b) / 255.0, 1.0)
|
||||
clear_pass: gfx.create_clear_pass( f32(cfg.bg_color.r) / 255.0, f32(cfg.bg_color.g) / 255.0,
|
||||
f32(cfg.bg_color.b) / 255.0, 1.0)
|
||||
scale: 1 // scale
|
||||
fons:0
|
||||
}
|
||||
|
@ -116,7 +117,7 @@ pub fn new_context(cfg Config) &GG {
|
|||
|
||||
pub fn (gg &GG) draw_text(x, y int, text string, cfg gx.TextCfg) {
|
||||
gg.fons.set_font(gg.font_normal)
|
||||
gg.fons.set_size(cfg.size)
|
||||
gg.fons.set_size(f32(cfg.size))
|
||||
ascender := f32(0.0)
|
||||
descender := f32(0.0)
|
||||
lh := f32(0.0)
|
||||
|
|
Loading…
Reference in New Issue