mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Remove Texture.Width()/Height()
This commit is contained in:
parent
5679120f29
commit
fd0ba69f0b
@ -9,6 +9,11 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
ebitenTextureWidth = 57
|
||||
ebitenTextureHeight = 26
|
||||
)
|
||||
|
||||
type Monochrome struct {
|
||||
ebitenTexture graphics.Texture
|
||||
ch chan bool
|
||||
@ -89,8 +94,8 @@ func (game *Monochrome) Update(context ebiten.GameContext) {
|
||||
<-game.ch
|
||||
|
||||
game.geometryMatrix = matrix.IdentityGeometry()
|
||||
tx := context.ScreenWidth()/2 - game.ebitenTexture.Width()/2
|
||||
ty := context.ScreenHeight()/2 - game.ebitenTexture.Height()/2
|
||||
tx := context.ScreenWidth()/2 - ebitenTextureWidth/2
|
||||
ty := context.ScreenHeight()/2 - ebitenTextureHeight/2
|
||||
game.geometryMatrix.Translate(float64(tx), float64(ty))
|
||||
}
|
||||
|
||||
|
@ -20,10 +20,10 @@ type Rects struct {
|
||||
}
|
||||
|
||||
const (
|
||||
rectTextureWidth = 16
|
||||
rectTextureWidth = 16
|
||||
rectTextureHeight = 16
|
||||
offscreenWidth = 256
|
||||
offscreenHeight = 240
|
||||
offscreenWidth = 256
|
||||
offscreenHeight = 240
|
||||
)
|
||||
|
||||
func New() *Rects {
|
||||
|
@ -10,6 +10,11 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
ebitenTextureWidth = 57
|
||||
ebitenTextureHeight = 26
|
||||
)
|
||||
|
||||
type Rotating struct {
|
||||
ebitenTexture graphics.Texture
|
||||
x int
|
||||
@ -40,7 +45,7 @@ func (game *Rotating) Update(context ebiten.GameContext) {
|
||||
game.x++
|
||||
|
||||
game.geometryMatrix = matrix.IdentityGeometry()
|
||||
tx, ty := float64(game.ebitenTexture.Width()), float64(game.ebitenTexture.Height())
|
||||
tx, ty := float64(ebitenTextureWidth), float64(ebitenTextureHeight)
|
||||
game.geometryMatrix.Translate(-tx/2, -ty/2)
|
||||
game.geometryMatrix.Rotate(float64(game.x) * 2 * math.Pi / float64(ebiten.FPS*10))
|
||||
game.geometryMatrix.Translate(tx/2, ty/2)
|
||||
|
@ -10,6 +10,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
ebitenTextureWidth = 57
|
||||
ebitenTextureHeight = 26
|
||||
)
|
||||
|
||||
type Sprite struct {
|
||||
width int
|
||||
height int
|
||||
@ -90,8 +95,8 @@ func (game *Sprites) Update(context ebiten.GameContext) {
|
||||
sprite := newSprite(
|
||||
context.ScreenWidth(),
|
||||
context.ScreenHeight(),
|
||||
game.ebitenTexture.Width(),
|
||||
game.ebitenTexture.Height())
|
||||
ebitenTextureWidth,
|
||||
ebitenTextureHeight)
|
||||
game.sprites = append(game.sprites, sprite)
|
||||
}
|
||||
}
|
||||
@ -112,7 +117,7 @@ func (game *Sprites) Draw(g graphics.Context) {
|
||||
LocationX: sprite.x,
|
||||
LocationY: sprite.y,
|
||||
Source: graphics.Rect{
|
||||
0, 0, texture.Width(), texture.Height(),
|
||||
0, 0, ebitenTextureWidth, ebitenTextureHeight,
|
||||
},
|
||||
}
|
||||
locations = append(locations, location)
|
||||
|
@ -39,8 +39,6 @@ type TextureFactory interface {
|
||||
|
||||
type Texture interface {
|
||||
ID() TextureID
|
||||
Width() int
|
||||
Height() int
|
||||
}
|
||||
|
||||
type TextureID int
|
||||
|
Loading…
Reference in New Issue
Block a user