mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
Rename TextureLocation to TexturePart
This commit is contained in:
parent
2b04f74614
commit
edceec9220
@ -20,7 +20,7 @@ type Sprite struct {
|
|||||||
vy int
|
vy int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSprite(screenWidth, screenHeight, width, height int) *Sprite {
|
func newSprite(screenWidth, screenHeight, width, height int) *Sprite {
|
||||||
maxX := screenWidth - width
|
maxX := screenWidth - width
|
||||||
maxY := screenHeight - height
|
maxY := screenHeight - height
|
||||||
sprite := &Sprite{
|
sprite := &Sprite{
|
||||||
@ -89,7 +89,7 @@ func (game *Sprites) Init(tf graphics.TextureFactory) {
|
|||||||
game.ebitenTexture = tf.NewTextureFromImage(img)
|
game.ebitenTexture = tf.NewTextureFromImage(img)
|
||||||
game.sprites = []*Sprite{}
|
game.sprites = []*Sprite{}
|
||||||
for i := 0; i < 1000; i++ {
|
for i := 0; i < 1000; i++ {
|
||||||
sprite := NewSprite(
|
sprite := newSprite(
|
||||||
game.ScreenWidth(),
|
game.ScreenWidth(),
|
||||||
game.ScreenHeight(),
|
game.ScreenHeight(),
|
||||||
game.ebitenTexture.Width,
|
game.ebitenTexture.Width,
|
||||||
@ -108,10 +108,10 @@ func (game *Sprites) Draw(g graphics.GraphicsContext, offscreen graphics.Texture
|
|||||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||||
|
|
||||||
// Draw the sprites
|
// Draw the sprites
|
||||||
locations := make([]graphics.TextureLocation, 0, len(game.sprites))
|
locations := make([]graphics.TexturePart, 0, len(game.sprites))
|
||||||
texture := game.ebitenTexture
|
texture := game.ebitenTexture
|
||||||
for _, sprite := range game.sprites {
|
for _, sprite := range game.sprites {
|
||||||
location := graphics.TextureLocation{
|
location := graphics.TexturePart{
|
||||||
LocationX: sprite.x,
|
LocationX: sprite.x,
|
||||||
LocationY: sprite.y,
|
LocationY: sprite.y,
|
||||||
Source: graphics.Rect{
|
Source: graphics.Rect{
|
||||||
|
@ -18,7 +18,7 @@ type Rect struct {
|
|||||||
Height int
|
Height int
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextureLocation struct {
|
type TexturePart struct {
|
||||||
LocationX int
|
LocationX int
|
||||||
LocationY int
|
LocationY int
|
||||||
Source Rect
|
Source Rect
|
||||||
@ -32,7 +32,7 @@ type GraphicsContext interface {
|
|||||||
geometryMatrix matrix.Geometry,
|
geometryMatrix matrix.Geometry,
|
||||||
colorMatrix matrix.Color)
|
colorMatrix matrix.Color)
|
||||||
DrawTextureParts(textureId TextureID,
|
DrawTextureParts(textureId TextureID,
|
||||||
locations []TextureLocation,
|
locations []TexturePart,
|
||||||
geometryMatrix matrix.Geometry,
|
geometryMatrix matrix.Geometry,
|
||||||
colorMatrix matrix.Color)
|
colorMatrix matrix.Color)
|
||||||
SetOffscreen(textureId TextureID)
|
SetOffscreen(textureId TextureID)
|
||||||
|
@ -121,13 +121,13 @@ func (context *GraphicsContext) DrawTexture(
|
|||||||
texture graphics.Texture,
|
texture graphics.Texture,
|
||||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||||
source := graphics.Rect{0, 0, texture.Width, texture.Height}
|
source := graphics.Rect{0, 0, texture.Width, texture.Height}
|
||||||
locations := []graphics.TextureLocation{{0, 0, source}}
|
locations := []graphics.TexturePart{{0, 0, source}}
|
||||||
context.DrawTextureParts(texture.ID, locations,
|
context.DrawTextureParts(texture.ID, locations,
|
||||||
geometryMatrix, colorMatrix)
|
geometryMatrix, colorMatrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *GraphicsContext) DrawTextureParts(
|
func (context *GraphicsContext) DrawTextureParts(
|
||||||
textureID graphics.TextureID, locations []graphics.TextureLocation,
|
textureID graphics.TextureID, locations []graphics.TexturePart,
|
||||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||||
|
|
||||||
texture := context.textures[textureID]
|
texture := context.textures[textureID]
|
||||||
|
Loading…
Reference in New Issue
Block a user