本文整理匯總了Golang中github.com/banthar/Go-SDL/sdl.Surface.Blit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Surface.Blit方法的具體用法?Golang Surface.Blit怎麽用?Golang Surface.Blit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/banthar/Go-SDL/sdl.Surface
的用法示例。
在下文中一共展示了Surface.Blit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: gameloop
func gameloop(screen *sdl.Surface) {
gc := &GameContext{screen, 320, 16}
for {
e := sdl.WaitEvent()
screen.FillRect(nil, 0x0)
gc.drawFloor()
gc.drawPlayer()
gc.drawObjects()
switch re := e.(type) {
case *sdl.QuitEvent:
return
case *sdl.MouseMotionEvent:
screen.FillRect(&sdl.Rect{
int16(re.X),
int16(re.Y),
50, 50}, 0xffffff)
screen.Blit(&sdl.Rect{
int16(re.X),
int16(re.Y),
0, 0}, playerTexture, nil)
fmt.Println(re.X, re.Y)
case *sdl.KeyboardEvent:
if re.Type == sdl.KEYDOWN {
keyname := sdl.GetKeyName(sdl.Key(re.Keysym.Sym))
fmt.Println("pressed:", keyname)
switch keyname {
case "right":
gc.moveRight()
case "left":
gc.moveLeft()
case "q":
return
}
} else if re.Type == sdl.KEYUP {
gc.resetPlayerSpeed()
}
default:
//fmt.Println("What the heck?!")
}
gc.Dump()
screen.Flip()
}
}