本文整理匯總了Golang中github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.Surface.Blit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Surface.Blit方法的具體用法?Golang Surface.Blit怎麽用?Golang Surface.Blit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/0xe2-0x9a-0x9b/Go-SDL/sdl.Surface
的用法示例。
在下文中一共展示了Surface.Blit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: drawPiece
func drawPiece(s *sdl.Surface, col, row int, p c4.Piece) {
// Load images
if redImage == nil {
redImage = sdl.Load("red.png")
}
if blackImage == nil {
blackImage = sdl.Load("black.png")
}
if noneImage == nil {
noneImage = sdl.Load("empty.png")
}
// Select image
var image *sdl.Surface
if p == c4.Red {
image = redImage
} else if p == c4.Black {
image = blackImage
} else {
image = noneImage
}
// Draw image
s.Blit(
&sdl.Rect{
int16(SCREEN_WIDTH * col / c4.MaxColumns),
int16(SCREEN_HEIGHT * (c4.MaxRows - row - 1) / c4.MaxRows),
0,
0},
image,
nil)
}
示例2: apply_surface
func apply_surface(x, y int16, src, dest *sdl.Surface) {
var offset sdl.Rect
offset.X = x
offset.Y = y
dest.Blit(&offset, src, nil)
}
示例3: draw_sdl
func draw_sdl(o *Object, s *sdl.Surface) {
var ss *sdl.Surface
if o.Collides {
ss = surfaceb
} else {
ss = surface
}
s.Blit(
&sdl.Rect{int16(float64(o.Pos.X) * ssw),
int16(float64(o.Pos.Y) * ssh),
uint16(float64((o.Pos.X + o.Size.X)) * ssw),
uint16(float64((o.Pos.Y + o.Size.Y)) * ssh)},
ss,
&sdl.Rect{0, 0, uint16(o.Size.X), uint16(o.Size.Y)})
}