mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Remove Game.Fps()
This commit is contained in:
parent
a35c74790c
commit
55331e2453
@ -24,10 +24,13 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
)
|
||||
|
||||
const (
|
||||
FPS = 60
|
||||
)
|
||||
|
||||
type Game interface {
|
||||
ScreenWidth() int
|
||||
ScreenHeight() int
|
||||
Fps() int
|
||||
Init(tf graphics.TextureFactory)
|
||||
Update(context GameContext)
|
||||
Draw(context graphics.Context)
|
||||
|
@ -40,10 +40,6 @@ func (game *Blank) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Blank) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Blank) Init(tf graphics.TextureFactory) {
|
||||
}
|
||||
|
||||
|
@ -47,10 +47,6 @@ func (game *Input) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Input) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Input) Init(tf graphics.TextureFactory) {
|
||||
file, err := os.Open("images/text.png")
|
||||
if err != nil {
|
||||
|
@ -51,10 +51,6 @@ func (game *Monochrome) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Monochrome) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Monochrome) Init(tf graphics.TextureFactory) {
|
||||
file, err := os.Open("images/ebiten.png")
|
||||
if err != nil {
|
||||
@ -90,24 +86,24 @@ func (game *Monochrome) update() {
|
||||
colorI := matrix.IdentityColor()
|
||||
colorMonochrome := matrix.Monochrome()
|
||||
for {
|
||||
for i := 0; i < game.Fps(); i++ {
|
||||
for i := 0; i < ebiten.FPS; i++ {
|
||||
<-game.ch
|
||||
rate := float64(i) / float64(game.Fps())
|
||||
rate := float64(i) / float64(ebiten.FPS)
|
||||
game.colorMatrix = mean(colorI, colorMonochrome, rate)
|
||||
game.ch <- true
|
||||
}
|
||||
for i := 0; i < game.Fps(); i++ {
|
||||
for i := 0; i < ebiten.FPS; i++ {
|
||||
<-game.ch
|
||||
game.colorMatrix = colorMonochrome
|
||||
game.ch <- true
|
||||
}
|
||||
for i := 0; i < game.Fps(); i++ {
|
||||
for i := 0; i < ebiten.FPS; i++ {
|
||||
<-game.ch
|
||||
rate := float64(i) / float64(game.Fps())
|
||||
rate := float64(i) / float64(ebiten.FPS)
|
||||
game.colorMatrix = mean(colorMonochrome, colorI, rate)
|
||||
game.ch <- true
|
||||
}
|
||||
for i := 0; i < game.Fps(); i++ {
|
||||
for i := 0; i < ebiten.FPS; i++ {
|
||||
<-game.ch
|
||||
game.colorMatrix = colorI
|
||||
game.ch <- true
|
||||
|
@ -45,10 +45,6 @@ func (game *Rects) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Rects) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Rects) Init(tf graphics.TextureFactory) {
|
||||
game.rectsTexture = tf.NewTexture(game.ScreenWidth(), game.ScreenHeight())
|
||||
}
|
||||
|
@ -48,10 +48,6 @@ func (game *Rotating) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Rotating) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Rotating) Init(tf graphics.TextureFactory) {
|
||||
file, err := os.Open("images/ebiten.png")
|
||||
if err != nil {
|
||||
@ -78,7 +74,7 @@ func (game *Rotating) Draw(g graphics.Context) {
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
tx, ty := float64(game.ebitenTexture.Width()), float64(game.ebitenTexture.Height())
|
||||
geometryMatrix.Translate(-tx/2, -ty/2)
|
||||
geometryMatrix.Rotate(float64(game.x) * 2 * math.Pi / float64(game.Fps()*10))
|
||||
geometryMatrix.Rotate(float64(game.x) * 2 * math.Pi / float64(ebiten.FPS*10))
|
||||
geometryMatrix.Translate(tx/2, ty/2)
|
||||
centerX := float64(game.ScreenWidth()) / 2
|
||||
centerY := float64(game.ScreenHeight()) / 2
|
||||
|
@ -96,10 +96,6 @@ func (game *Sprites) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Sprites) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Sprites) Init(tf graphics.TextureFactory) {
|
||||
file, err := os.Open("images/ebiten.png")
|
||||
if err != nil {
|
||||
|
@ -41,10 +41,6 @@ func (game *Terminate) ScreenHeight() int {
|
||||
return 240
|
||||
}
|
||||
|
||||
func (game *Terminate) Fps() int {
|
||||
return 60
|
||||
}
|
||||
|
||||
func (game *Terminate) Init(tf graphics.TextureFactory) {
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ func Run(game ebiten.Game, screenScale int, title string) {
|
||||
|
||||
go func() {
|
||||
frameTime := time.Duration(
|
||||
int64(time.Second) / int64(game.Fps()))
|
||||
int64(time.Second) / int64(ebiten.FPS))
|
||||
tick := time.Tick(frameTime)
|
||||
gameContext := &GameContext{
|
||||
inputState: ebiten.InputState{-1, -1},
|
||||
|
Loading…
Reference in New Issue
Block a user