当前位置: 首页>>代码示例>>Golang>>正文


Golang Window.SetShouldClose方法代码示例

本文整理汇总了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)
	}
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:36,代码来源:glfwtest.go

示例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)
	}
}
开发者ID:maleck13,项目名称:jigsaws,代码行数:7,代码来源:helloworldgl.go

示例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)
	}
}
开发者ID:jhautefeuille,项目名称:hellochipmunk,代码行数:27,代码来源:main.go

示例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)
	}
}
开发者ID:tbogdala,项目名称:free,代码行数:8,代码来源:input.go

示例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)
	}
}
开发者ID:cstegel,项目名称:opengl-samples-golang,代码行数:7,代码来源:hello_window.go

示例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)
	}
}
开发者ID:Ozzadar,项目名称:golang-vr-opengl-engine,代码行数:9,代码来源:LeftRightColorOculusDK2.go

示例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()
	}
}
开发者ID:tbogdala,项目名称:cubez,代码行数:9,代码来源:ballistic.go

示例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
	}
}
开发者ID:Ariemeth,项目名称:frame-assault-2,代码行数:12,代码来源:engine.go

示例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)
		}
	}
}
开发者ID:buwilliams,项目名称:go2dgame,代码行数:16,代码来源:triangle.go

示例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
	}
}
开发者ID:himanshushekhar,项目名称:golang-flappybirdclone,代码行数:19,代码来源:main.go

示例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
	}
}
开发者ID:Geemili,项目名称:maze-rogue,代码行数:21,代码来源:maze-rogue.go

示例12: charCallBack

func charCallBack(w *glfw.Window, char rune) {
	if char == 'q' {
		w.SetShouldClose(true)
	}
}
开发者ID:rdterner,项目名称:gl,代码行数:5,代码来源:hello.go

示例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 {
//.........这里部分代码省略.........
开发者ID:YagoCarballo,项目名称:Go-OpenGL-Lab-3,代码行数:101,代码来源:basic.go

示例14: onClose

func onClose(window *glfw.Window) {
	window.SetShouldClose(true)
}
开发者ID:himanshushekhar,项目名称:golang-flappybirdclone,代码行数:3,代码来源:main.go


注:本文中的github.com/go-gl/glfw/v3/1/glfw.Window.SetShouldClose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。