mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Renamed methods
This commit is contained in:
parent
71606b78a9
commit
03fae7032a
@ -56,8 +56,7 @@ func (game *RotatingImage) Draw(g graphics.GraphicsContext, offscreen graphics.T
|
||||
centerY := float64(game.ScreenHeight()) / 2
|
||||
geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
|
||||
|
||||
g.DrawTexture(game.ebitenTexture.ID,
|
||||
graphics.Rect{0, 0, int(tx), int(ty)},
|
||||
g.DrawTexture(game.ebitenTexture,
|
||||
geometryMatrix,
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -11,26 +11,26 @@ import (
|
||||
)
|
||||
|
||||
type Sprite struct {
|
||||
width int
|
||||
width int
|
||||
height int
|
||||
ch chan bool
|
||||
x int
|
||||
y int
|
||||
vx int
|
||||
vy int
|
||||
ch chan bool
|
||||
x int
|
||||
y int
|
||||
vx int
|
||||
vy int
|
||||
}
|
||||
|
||||
func NewSprite(screenWidth, screenHeight, width, height int) *Sprite {
|
||||
maxX := screenWidth - width
|
||||
maxY := screenHeight - height
|
||||
sprite := &Sprite{
|
||||
width: width,
|
||||
width: width,
|
||||
height: height,
|
||||
ch: make(chan bool),
|
||||
x: rand.Intn(maxX),
|
||||
y: rand.Intn(maxY),
|
||||
vx: rand.Intn(2)*2 - 1,
|
||||
vy: rand.Intn(2)*2 - 1,
|
||||
ch: make(chan bool),
|
||||
x: rand.Intn(maxX),
|
||||
y: rand.Intn(maxY),
|
||||
vx: rand.Intn(2)*2 - 1,
|
||||
vy: rand.Intn(2)*2 - 1,
|
||||
}
|
||||
go sprite.update(screenWidth, screenHeight)
|
||||
return sprite
|
||||
@ -61,6 +61,7 @@ func (sprite *Sprite) Update() {
|
||||
type Sprites struct {
|
||||
ebitenTexture graphics.Texture
|
||||
sprites []*Sprite
|
||||
angle int
|
||||
}
|
||||
|
||||
func NewSprites() *Sprites {
|
||||
@ -102,6 +103,7 @@ func (game *Sprites) Update() {
|
||||
for _, sprite := range game.sprites {
|
||||
sprite.Update()
|
||||
}
|
||||
game.angle++
|
||||
}
|
||||
|
||||
func (game *Sprites) Draw(g graphics.GraphicsContext, offscreen graphics.Texture) {
|
||||
@ -120,8 +122,9 @@ func (game *Sprites) Draw(g graphics.GraphicsContext, offscreen graphics.Texture
|
||||
}
|
||||
locations = append(locations, location)
|
||||
}
|
||||
g.DrawTextures(texture.ID, locations,
|
||||
matrix.IdentityGeometry(), matrix.IdentityColor())
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
g.DrawTextureParts(texture.ID, locations,
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -27,12 +27,13 @@ type TextureLocation struct {
|
||||
type GraphicsContext interface {
|
||||
Clear()
|
||||
Fill(color color.Color)
|
||||
DrawTexture(textureId TextureID,
|
||||
source Rect,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color)
|
||||
DrawTextures(textureId TextureID,
|
||||
DrawTexture(texture Texture,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawTextureParts(textureId TextureID,
|
||||
locations []TextureLocation,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color)
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
SetOffscreen(textureId TextureID)
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,7 @@ func (device *Device) Update() {
|
||||
{0, scale, 0},
|
||||
},
|
||||
}
|
||||
g.DrawTexture(device.offscreenTexture.ID,
|
||||
graphics.Rect{
|
||||
0, 0, device.screenWidth, device.screenHeight,
|
||||
},
|
||||
g.DrawTexture(device.offscreenTexture,
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
g.flush()
|
||||
}
|
||||
|
@ -66,14 +66,15 @@ func (context *GraphicsContext) DrawRect(x, y, width, height int, clr color.Colo
|
||||
}
|
||||
|
||||
func (context *GraphicsContext) DrawTexture(
|
||||
textureID graphics.TextureID, source graphics.Rect,
|
||||
texture graphics.Texture,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
source := graphics.Rect{0, 0, texture.Width, texture.Height}
|
||||
locations := []graphics.TextureLocation{{0, 0, source}}
|
||||
context.DrawTextures(textureID, locations,
|
||||
context.DrawTextureParts(texture.ID, locations,
|
||||
geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
func (context *GraphicsContext) DrawTextures(
|
||||
func (context *GraphicsContext) DrawTextureParts(
|
||||
textureID graphics.TextureID, locations []graphics.TextureLocation,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user