// 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) } }
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) } }
// 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) } }
// 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) } }
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) } }
/* ***************** 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) } }
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() } }
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 } }
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) } } }
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 } }
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 } }
func charCallBack(w *glfw.Window, char rune) { if char == 'q' { w.SetShouldClose(true) } }
// // 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 { cube.DrawMode = 0 } } }
func onClose(window *glfw.Window) { window.SetShouldClose(true) }