本文整理匯總了Golang中github.com/neagix/Go-SDL/sdl.Surface.FillRect方法的典型用法代碼示例。如果您正苦於以下問題:Golang Surface.FillRect方法的具體用法?Golang Surface.FillRect怎麽用?Golang Surface.FillRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/neagix/Go-SDL/sdl.Surface
的用法示例。
在下文中一共展示了Surface.FillRect方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Draw
// Draw directs each layer, starting from the bottom, to draw to the
// screen, and then updates the necessary parts of the screen.
func (stack LayerStack) Draw(screen *sdl.Surface) {
screen.FillRect(
&sdl.Rect{X: 0, Y: 0, W: uint16(screen.W), H: uint16(screen.H)},
0,
)
for i, layer := range stack {
top := i == len(stack)-1
layer.Draw(screen, top)
}
screen.Flip()
}
示例3: 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)},
)
}
示例4: Draw
func (w *Window) Draw(screen *sdl.Surface) {
screen.FillRect(
&sdl.Rect{
X: w.X,
Y: w.Y,
W: w.W,
H: w.H,
},
ui.ColorToInt(w.BorderColor),
)
screen.FillRect(
&sdl.Rect{
X: w.X + int16(w.BorderWidth),
Y: w.Y + int16(w.BorderWidth),
W: w.W - w.BorderWidth*2,
H: w.H - w.BorderWidth*2,
},
ui.ColorToInt(w.BGColor),
)
for _, child := range w.children {
child.Draw(screen)
}
}
示例5: 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)
}
}