mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tetris/glfw: fix warnings
This commit is contained in:
parent
59378dce46
commit
efdadc3758
@ -382,10 +382,11 @@ fn key_down(wnd voidptr, key, code, action, mods int) {
|
|||||||
// Fetch the game object stored in the user pointer
|
// Fetch the game object stored in the user pointer
|
||||||
mut game := &Game(glfw.get_window_user_pointer(wnd))
|
mut game := &Game(glfw.get_window_user_pointer(wnd))
|
||||||
// global keys
|
// global keys
|
||||||
switch key {
|
match key {
|
||||||
case glfw.KEY_ESCAPE:
|
glfw.KEY_ESCAPE {
|
||||||
glfw.set_should_close(wnd, true)
|
glfw.set_should_close(wnd, true)
|
||||||
case glfw.key_space:
|
}
|
||||||
|
glfw.key_space {
|
||||||
if game.state == .running {
|
if game.state == .running {
|
||||||
game.state = .paused
|
game.state = .paused
|
||||||
} else if game.state == .paused {
|
} else if game.state == .paused {
|
||||||
@ -395,12 +396,14 @@ fn key_down(wnd voidptr, key, code, action, mods int) {
|
|||||||
game.state = .running
|
game.state = .running
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if game.state != .running {
|
if game.state != .running {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// keys while game is running
|
// keys while game is running
|
||||||
switch key {
|
match key {
|
||||||
case glfw.KeyUp:
|
glfw.KeyUp {
|
||||||
// Rotate the tetro
|
// Rotate the tetro
|
||||||
old_rotation_idx := game.rotation_idx
|
old_rotation_idx := game.rotation_idx
|
||||||
game.rotation_idx++
|
game.rotation_idx++
|
||||||
@ -412,15 +415,18 @@ fn key_down(wnd voidptr, key, code, action, mods int) {
|
|||||||
game.rotation_idx = old_rotation_idx
|
game.rotation_idx = old_rotation_idx
|
||||||
game.get_tetro()
|
game.get_tetro()
|
||||||
}
|
}
|
||||||
|
|
||||||
if game.pos_x < 0 {
|
if game.pos_x < 0 {
|
||||||
game.pos_x = 1
|
game.pos_x = 1
|
||||||
}
|
}
|
||||||
case glfw.KeyLeft:
|
}
|
||||||
|
glfw.KeyLeft {
|
||||||
game.move_right(-1)
|
game.move_right(-1)
|
||||||
case glfw.KeyRight:
|
}
|
||||||
|
glfw.KeyRight {
|
||||||
game.move_right(1)
|
game.move_right(1)
|
||||||
case glfw.KeyDown:
|
}
|
||||||
|
glfw.KeyDown {
|
||||||
game.move_tetro() // drop faster when the player presses <down>
|
game.move_tetro() // drop faster when the player presses <down>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -27,18 +27,18 @@ import gl
|
|||||||
// #flag darwin -framework Cocoa
|
// #flag darwin -framework Cocoa
|
||||||
// #flag darwin -framework CoreVideo
|
// #flag darwin -framework CoreVideo
|
||||||
// #flag darwin -framework IOKit
|
// #flag darwin -framework IOKit
|
||||||
const (
|
pub const (
|
||||||
RESIZABLE = 1
|
RESIZABLE = 1
|
||||||
DECORATED = 2
|
DECORATED = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
pub const (
|
||||||
KEY_ESCAPE = 256
|
KEY_ESCAPE = 256
|
||||||
key_space = 32
|
key_space = 32
|
||||||
KEY_LEFT_SUPER = 343
|
KEY_LEFT_SUPER = 343
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
pub const (
|
||||||
KeyUp = 265
|
KeyUp = 265
|
||||||
KeyLeft = 263
|
KeyLeft = 263
|
||||||
KeyRight = 262
|
KeyRight = 262
|
||||||
|
Loading…
Reference in New Issue
Block a user