本文整理匯總了Golang中github.com/neagix/Go-SDL/sdl.Surface.Blit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Surface.Blit方法的具體用法?Golang Surface.Blit怎麽用?Golang Surface.Blit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/neagix/Go-SDL/sdl.Surface
的用法示例。
在下文中一共展示了Surface.Blit方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Render
func (g *guiLayer) Render(target *sdl.Surface) {
if g.child != nil {
g.child.Render(target)
}
target.FillRect(
&sdl.Rect{
X: 20,
Y: 300,
H: uint16(30 + (30 * g.game.NumPlayers)),
W: 200,
},
0xffffff,
)
for i := 0; i < g.game.NumPlayers; i++ {
p := g.game.GetPlayer(i)
str := fmt.Sprintf("Player %d: %d - %d - %d", i, p.Money.Get(), p.Money.GetIncome(), p.GetLives())
txt_surface := ttf.RenderText_Solid(g.font, str, sdl.Color{})
if txt_surface == nil {
fmt.Printf("RenderText Solid failed: %s", sdl.GetError())
}
target.Blit(
&sdl.Rect{
X: 50,
Y: int16(320 + (i * 30)),
},
txt_surface,
nil,
)
}
}
示例2: Render
func (g *stageLayer) Render(target *sdl.Surface) {
target.Blit(
&sdl.Rect{
X: 0,
Y: 0,
W: uint16(g.size_x),
H: uint16(g.size_y),
},
g.surface,
nil,
)
if g.child != nil {
g.child.Render(target)
}
}
示例3: Render
func (g *buildLayer) Render(target *sdl.Surface) {
x_off, y_off := g.GetXYOffsets()
square_x, square_y := util.GetMouse(g.square_size, x_off, y_off, false)
var build_colour uint32
if g.controls.GetPlayer().Buildable(square_y/g.square_size, square_x/g.square_size) {
build_colour = 0x00ff00
} else {
build_colour = 0xff0000
}
g.buildSurface.FillRect(
&sdl.Rect{
X: 0,
Y: 0,
H: 128,
W: 128,
},
build_colour,
)
g.buildSurface.Blit(
&sdl.Rect{
X: 0,
Y: 0,
},
g.texture_map.GetName("turret_basic").Surface,
nil,
)
target.Blit(
&sdl.Rect{
X: int16(square_x),
Y: int16(square_y),
},
g.buildSurface,
nil,
)
if g.child != nil {
g.child.Render(target)
}
}
示例4: Draw
func (m *MainMenu) Draw(screen *sdl.Surface, top bool) {
w := uint16(m.titleText.W)
h := uint16(m.titleText.H)
screen.Blit(
&sdl.Rect{
X: int16(screen.W - m.titleText.W - 50),
Y: 15,
W: w,
H: h,
},
m.titleText,
&sdl.Rect{X: 0, Y: 0, W: w, H: h},
)
m.menuItemSelected = ""
y := int16(screen.H - menuItemYOffset)
for _, label := range m.itemLabels {
item := m.menuItems[label]
mx := int16(m.mouseX)
my := int16(m.mouseY)
w = uint16(item.W)
h = uint16(item.H)
y -= int16(item.H)
if ui.Overlaps(mx, my, menuItemXOffset, y, w, h) {
if top {
item = m.hoverItems[label]
}
m.menuItemSelected = label
}
screen.Blit(
&sdl.Rect{
X: menuItemXOffset,
Y: int16(y),
W: w,
H: h,
},
item,
&sdl.Rect{X: 0, Y: 0, W: w, H: h},
)
}
}
示例5: Render
func (g *panLayer) Render(target *sdl.Surface) {
g.child.Render(g.surface)
g.surface.Flip()
parent_x, parent_y := g.parent.GetSize()
target.Blit(
&sdl.Rect{
X: 0,
Y: 0,
W: parent_x,
H: parent_y,
},
g.surface,
&sdl.Rect{
X: int16(g.view_x),
Y: int16(g.view_y),
W: parent_x,
H: parent_y,
},
)
}
示例6: Draw
func (t *TextBox) Draw(screen *sdl.Surface) {
y := t.Y
lineSpacing := 0
for _, line := range t.lines {
if line == nil {
y += int16(lineSpacing)
continue
} else {
lineSpacing = int(line.H) / 2
}
if uint16(y)+uint16(line.H)-uint16(t.Y) > t.H {
continue
}
x := int16(t.X)
switch t.FontAlignment {
case Left:
x += 0
case Center:
x += (int16(t.W) - int16(line.W)) / 2
case Right:
x += int16(t.W) - int16(line.W)
}
screen.Blit(
&sdl.Rect{
X: x,
Y: y,
W: uint16(line.W),
H: uint16(line.H),
},
line,
&sdl.Rect{W: uint16(line.W), H: uint16(line.H)},
)
y += int16(line.H)
}
}
示例7: Draw
func (b *Button) Draw(screen *sdl.Surface) {
screen.FillRect(
&sdl.Rect{
X: b.X,
Y: b.Y,
W: b.W,
H: b.H,
},
ui.ColorToInt(b.BorderColor),
)
var fillColor sdl.Color
if b.hovered {
fillColor = b.HoverColor
} else {
fillColor = b.BGColor
}
screen.FillRect(
&sdl.Rect{
X: b.X + int16(b.BorderWidth),
Y: b.Y + int16(b.BorderWidth),
W: b.W - 2*uint16(b.BorderWidth),
H: b.H - 2*uint16(b.BorderWidth),
},
ui.ColorToInt(fillColor),
)
screen.Blit(
&sdl.Rect{
X: b.X + int16((int32(b.W)-b.labelText.W)/2),
Y: b.Y + int16((int32(b.H)-b.labelText.H)/2),
W: uint16(b.labelText.W),
H: uint16(b.labelText.H),
},
b.labelText,
&sdl.Rect{W: uint16(b.labelText.W), H: uint16(b.labelText.H)},
)
}
示例8: Render
func (g *entityLayer) Render(target *sdl.Surface) {
var units = make(map[string]*sdl.Surface)
turret_texture := g.texture_map.GetName("turret_basic").Surface
for i := 0; i < g.game.NumPlayers; i++ {
player := g.game.GetPlayer(i)
for loc, _ := range player.Towers {
target.Blit(
&sdl.Rect{
X: int16(loc.Col * g.square_size),
Y: int16(loc.Row * g.square_size),
},
turret_texture,
nil,
)
}
for _, u := range player.Units {
unit_name := u.Type.Name
_, ok := units[unit_name]
if !ok {
units[unit_name] = g.texture_map.GetName(unit_name).Surface
}
loc := u.Loc
target.Blit(
&sdl.Rect{
X: int16(loc.Col*float64(g.square_size)) - 32,
Y: int16(loc.Row*float64(g.square_size)) - 32,
},
units[unit_name],
nil,
)
health := 64 * (float64(u.Health) / float64(u.Type.Health))
target.FillRect(
&sdl.Rect{
X: int16(loc.Col*float64(g.square_size)) - 32,
Y: int16(loc.Row*float64(g.square_size)) - 32,
W: 5,
H: 64,
},
0x000000,
)
if health > 0 {
target.FillRect(
&sdl.Rect{
X: int16(loc.Col*float64(g.square_size)) - 32,
Y: int16(loc.Row*float64(g.square_size)) - 32,
W: 5,
H: uint16(health),
},
0x00ff00,
)
}
}
}
if g.child != nil {
g.child.Render(target)
}
}