Renamed methods

This commit is contained in:
Hajime Hoshi 2013-06-22 02:42:14 +09:00
parent 71606b78a9
commit 03fae7032a
5 changed files with 29 additions and 28 deletions

View File

@ -56,8 +56,7 @@ func (game *RotatingImage) Draw(g graphics.GraphicsContext, offscreen graphics.T
centerY := float64(game.ScreenHeight()) / 2 centerY := float64(game.ScreenHeight()) / 2
geometryMatrix.Translate(centerX-tx/2, centerY-ty/2) geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
g.DrawTexture(game.ebitenTexture.ID, g.DrawTexture(game.ebitenTexture,
graphics.Rect{0, 0, int(tx), int(ty)},
geometryMatrix, geometryMatrix,
matrix.IdentityColor()) matrix.IdentityColor())
} }

View File

@ -61,6 +61,7 @@ func (sprite *Sprite) Update() {
type Sprites struct { type Sprites struct {
ebitenTexture graphics.Texture ebitenTexture graphics.Texture
sprites []*Sprite sprites []*Sprite
angle int
} }
func NewSprites() *Sprites { func NewSprites() *Sprites {
@ -102,6 +103,7 @@ func (game *Sprites) Update() {
for _, sprite := range game.sprites { for _, sprite := range game.sprites {
sprite.Update() sprite.Update()
} }
game.angle++
} }
func (game *Sprites) Draw(g graphics.GraphicsContext, offscreen graphics.Texture) { 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) locations = append(locations, location)
} }
g.DrawTextures(texture.ID, locations, geometryMatrix := matrix.IdentityGeometry()
matrix.IdentityGeometry(), matrix.IdentityColor()) g.DrawTextureParts(texture.ID, locations,
geometryMatrix, matrix.IdentityColor())
} }
func init() { func init() {

View File

@ -27,12 +27,13 @@ type TextureLocation struct {
type GraphicsContext interface { type GraphicsContext interface {
Clear() Clear()
Fill(color color.Color) Fill(color color.Color)
DrawTexture(textureId TextureID, DrawTexture(texture Texture,
source Rect, geometryMatrix matrix.Geometry,
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) colorMatrix matrix.Color)
DrawTextures(textureId TextureID, DrawTextureParts(textureId TextureID,
locations []TextureLocation, locations []TextureLocation,
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) geometryMatrix matrix.Geometry,
colorMatrix matrix.Color)
SetOffscreen(textureId TextureID) SetOffscreen(textureId TextureID)
} }

View File

@ -55,10 +55,7 @@ func (device *Device) Update() {
{0, scale, 0}, {0, scale, 0},
}, },
} }
g.DrawTexture(device.offscreenTexture.ID, g.DrawTexture(device.offscreenTexture,
graphics.Rect{
0, 0, device.screenWidth, device.screenHeight,
},
geometryMatrix, matrix.IdentityColor()) geometryMatrix, matrix.IdentityColor())
g.flush() g.flush()
} }

View File

@ -66,14 +66,15 @@ func (context *GraphicsContext) DrawRect(x, y, width, height int, clr color.Colo
} }
func (context *GraphicsContext) DrawTexture( func (context *GraphicsContext) DrawTexture(
textureID graphics.TextureID, source graphics.Rect, texture graphics.Texture,
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) { geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
source := graphics.Rect{0, 0, texture.Width, texture.Height}
locations := []graphics.TextureLocation{{0, 0, source}} locations := []graphics.TextureLocation{{0, 0, source}}
context.DrawTextures(textureID, locations, context.DrawTextureParts(texture.ID, locations,
geometryMatrix, colorMatrix) geometryMatrix, colorMatrix)
} }
func (context *GraphicsContext) DrawTextures( func (context *GraphicsContext) DrawTextureParts(
textureID graphics.TextureID, locations []graphics.TextureLocation, textureID graphics.TextureID, locations []graphics.TextureLocation,
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) { geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {