本文整理匯總了Golang中github.com/google/gxui.Driver.Terminate方法的典型用法代碼示例。如果您正苦於以下問題:Golang Driver.Terminate方法的具體用法?Golang Driver.Terminate怎麽用?Golang Driver.Terminate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/gxui.Driver
的用法示例。
在下文中一共展示了Driver.Terminate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: appMain
func appMain(driver gxui.Driver) {
theme = light.CreateTheme(driver)
window = theme.CreateWindow(800, 600, "Snake")
playGround = field.Create(800, 600, 20, 20)
sn = snake.Create(math.Point{X: 380, Y: 200}, math.Point{X: 380, Y: 280}, 20)
drawScene(driver)
fmt.Println(sn.Direction())
window.OnKeyUp(func(event gxui.KeyboardEvent) {
dir := sn.Direction()
key := event.Key
switch {
case key == gxui.KeyRight && dir == snake.Top:
sn.TurnRight()
case key == gxui.KeyRight && dir == snake.Bottom:
sn.TurnLeft()
case key == gxui.KeyLeft && dir == snake.Top:
sn.TurnLeft()
case key == gxui.KeyLeft && dir == snake.Bottom:
sn.TurnRight()
case key == gxui.KeyUp && dir == snake.Left:
sn.TurnRight()
case key == gxui.KeyUp && dir == snake.Right:
sn.TurnLeft()
case key == gxui.KeyDown && dir == snake.Left:
sn.TurnLeft()
case key == gxui.KeyDown && dir == snake.Right:
sn.TurnRight()
}
})
ticker := time.NewTicker(time.Millisecond * 200)
go func() {
for _ = range ticker.C {
driver.Call(func() {
(&sn).Move()
drawScene(driver)
})
}
}()
window.OnClose(func() {
driver.Terminate()
ticker.Stop()
})
}