本文整理汇总了Golang中github.com/go-gl/glfw/v3/1/glfw.Window.SetShouldClose方法的典型用法代码示例。如果您正苦于以下问题:Golang Window.SetShouldClose方法的具体用法?Golang Window.SetShouldClose怎么用?Golang Window.SetShouldClose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/go-gl/glfw/v3/1/glfw.Window
的用法示例。
在下文中一共展示了Window.SetShouldClose方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: keyCallback
// key events are a way to get input from GLFW.
func keyCallback(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
//if u only want the on press, do = && && action == glfw.Press
if key == glfw.KeyW && action == glfw.Press {
fmt.Printf("W Pressed!\n")
player.moveUp()
}
if key == glfw.KeyA { //&& action == glfw.Press
fmt.Printf("A Pressed!\n")
if action == glfw.Release {
player.moving_left = false
}
if action == glfw.Press {
player.moving_left = true
}
// player.moveLeft()
}
if key == glfw.KeyS {
fmt.Printf("S Pressed!\n")
player.moveDown()
}
if key == glfw.KeyD {
fmt.Printf("D Pressed!\n")
if action == glfw.Release {
player.moving_right = false
}
if action == glfw.Press {
player.moving_right = true
}
// player.moveRight()
}
if key == glfw.KeyEscape && action == glfw.Press {
w.SetShouldClose(true)
}
}
示例2: onKey
func onKey(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
switch {
case key == glfw.KeyEscape && action == glfw.Press,
key == glfw.KeyQ && action == glfw.Press:
w.SetShouldClose(true)
}
}
示例3: keyCallback
// key events are a way to get input from GLFW.
func keyCallback(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
//if u only want the on press, do = && && action == glfw.Press
player := game.Player
if key == glfw.KeyW && action == glfw.Press {
fmt.Printf("W Pressed!\n")
player.Jump()
}
if key == glfw.KeyA { //&& action == glfw.Press
fmt.Printf("A Pressed!\n")
player.MoveLeft()
}
if key == glfw.KeyS {
fmt.Printf("S Pressed!\n")
}
if key == glfw.KeyD {
fmt.Printf("D Pressed!\n")
player.MoveRight()
}
if key == glfw.KeyEscape && action == glfw.Press {
w.SetShouldClose(true)
}
}
示例4: gameKeyCallback
// mainKeyCallback is the main keyboard input callback for the game
func gameKeyCallback(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
switch {
// NOTE: For testing purposes, we'll exit on esc button
case key == glfw.KeyEscape && action == glfw.Press:
w.SetShouldClose(true)
}
}
示例5: keyCallback
func keyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
// When a user presses the escape key, we set the WindowShouldClose property to true,
// which closes the application
if key == glfw.KeyEscape && action == glfw.Press {
window.SetShouldClose(true)
}
}
示例6: onKey
/* ***************** KEYBOARD INPUT ******************** */
func onKey(w *glfw.Window, key glfw.Key, scancode int,
action glfw.Action, mods glfw.ModifierKey) {
if key == glfw.KeyEscape && action == glfw.Press {
fmt.Println("Close Window")
w.SetShouldClose(true)
}
}
示例7: keyCallback
func keyCallback(w *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
// Key W == close app
if key == glfw.KeyEscape && action == glfw.Press {
w.SetShouldClose(true)
}
if key == glfw.KeySpace && action == glfw.Press {
fire()
}
}
示例8: onKey
func onKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) {
if action != glfw.Press {
return
}
switch glfw.Key(k) {
case glfw.KeyEscape:
window.SetShouldClose(true)
default:
return
}
}
示例9: keypress
func keypress(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
// Pressing escape will close the window
if key == glfw.KeyEscape {
window.SetShouldClose(true)
}
if action == glfw.Release {
s := strconv.Itoa(scancode)
if key == glfw.KeyA && mods == glfw.ModShift {
fmt.Println("Key 'A' pressed!")
} else if key == glfw.KeyA {
fmt.Println("Key 'a' pressed!")
} else {
fmt.Println("Key '" + s + "' pressed!" + s)
}
}
}
示例10: onKey
func onKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) {
if action != glfw.Press {
return
}
// disable if event handlers are flagged off
if birdCollided && (k != glfw.KeyEscape) {
return
}
switch glfw.Key(k) {
case glfw.KeyEscape:
window.SetShouldClose(true)
case glfw.KeySpace:
jump()
default:
return
}
}
示例11: OnKey
func OnKey(window *glfw.Window, k glfw.Key, s int, action glfw.Action, mods glfw.ModifierKey) {
if action != glfw.Press {
return
}
nx, ny := game.PlayerX, game.PlayerY
switch k {
case glfw.KeyLeft:
nx--
case glfw.KeyRight:
nx++
case glfw.KeyUp:
ny++
case glfw.KeyDown:
ny--
case glfw.KeyEscape:
window.SetShouldClose(true)
}
if nx >= 0 && nx < game.Width && ny >= 0 && ny < game.Height && game.Tiles[(ny*game.Width)+nx] == 226 {
game.PlayerX, game.PlayerY = nx, ny
}
}
示例12: charCallBack
func charCallBack(w *glfw.Window, char rune) {
if char == 'q' {
w.SetShouldClose(true)
}
}
示例13: keyCallback
//
// key Callback
// This function gets called when a key is pressed
//
// @param window (*glfw.Window) a pointer to the window
// @param key (glfw.Key) the pressed key
// @param scancode (int) the scancode
// @param action (glfw.Action) the state of the key
// @param mods (glfw.ModifierKey) the pressed modified keys.
//
func keyCallback(window *glfw.Window, key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
// React only if the key was just pressed
if action != glfw.Press {
return
}
switch key {
// If the Key Excape is pressed, it closes the App
case glfw.KeyEscape:
if action == glfw.Press {
window.SetShouldClose(true)
}
break
case glfw.KeyQ:
angle_inc_x += 0.05
break
case glfw.KeyW:
angle_inc_x -= 0.05
break
case glfw.KeyE:
angle_inc_y += 0.05
break
case glfw.KeyR:
angle_inc_y -= 0.05
break
case glfw.KeyT:
angle_inc_z -= 0.05
break
case glfw.KeyY:
angle_inc_z += 0.05
break
case glfw.KeyA:
scale += 0.02
break
case glfw.KeyS:
scale -= 0.02
break
case glfw.KeyZ:
x -= 0.05
break
case glfw.KeyX:
x += 0.05
break
case glfw.KeyC:
y -= 0.05
break
case glfw.KeyV:
y += 0.05
break
case glfw.KeyB:
z -= 0.05
break
case glfw.KeyN:
z += 0.05
break
case glfw.KeyM:
if colourmode == 1 {
colourmode = 0
} else {
colourmode = 1
}
fmt.Printf("Colour Mode: %s \n", colourmode)
break
// Cycle between drawing vertices, mesh and filled polygons
case glfw.KeyK:
sphere.DrawMode++
if sphere.DrawMode > 2 {
sphere.DrawMode = 0
}
break
case glfw.KeyL:
cube.DrawMode++
if cube.DrawMode > 2 {
//.........这里部分代码省略.........
示例14: onClose
func onClose(window *glfw.Window) {
window.SetShouldClose(true)
}