From bcb8c0d45a51a173bd3845c3a8127b5ba31b62db Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 23 Nov 2013 19:51:24 +0900 Subject: [PATCH] Remove ebiten.FPS --- ebiten.go | 4 ---- example/game/monochrome/monochrome.go | 13 +++++++------ example/game/rotating/rotating.go | 4 +++- example/main.go | 5 +++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ebiten.go b/ebiten.go index cdf8e669a..6a1adfc1b 100644 --- a/ebiten.go +++ b/ebiten.go @@ -4,10 +4,6 @@ import ( "github.com/hajimehoshi/go-ebiten/graphics" ) -const ( - FPS = 60 -) - type Game interface { InitTextures(tf graphics.TextureFactory) Update(context GameContext) diff --git a/example/game/monochrome/monochrome.go b/example/game/monochrome/monochrome.go index 8750556b3..41bfff73a 100644 --- a/example/game/monochrome/monochrome.go +++ b/example/game/monochrome/monochrome.go @@ -61,27 +61,28 @@ func mean(a, b matrix.Color, k float64) matrix.Color { } func (game *Monochrome) update() { + const fps = 60 colorI := matrix.IdentityColor() colorMonochrome := matrix.Monochrome() for { - for i := 0; i < ebiten.FPS; i++ { + for i := 0; i < fps; i++ { <-game.ch - rate := float64(i) / float64(ebiten.FPS) + rate := float64(i) / float64(fps) game.colorMatrix = mean(colorI, colorMonochrome, rate) game.ch <- true } - for i := 0; i < ebiten.FPS; i++ { + for i := 0; i < fps; i++ { <-game.ch game.colorMatrix = colorMonochrome game.ch <- true } - for i := 0; i < ebiten.FPS; i++ { + for i := 0; i < fps; i++ { <-game.ch - rate := float64(i) / float64(ebiten.FPS) + rate := float64(i) / float64(fps) game.colorMatrix = mean(colorMonochrome, colorI, rate) game.ch <- true } - for i := 0; i < ebiten.FPS; i++ { + for i := 0; i < fps; i++ { <-game.ch game.colorMatrix = colorI game.ch <- true diff --git a/example/game/rotating/rotating.go b/example/game/rotating/rotating.go index b18e131d0..8f9a4f129 100644 --- a/example/game/rotating/rotating.go +++ b/example/game/rotating/rotating.go @@ -42,12 +42,14 @@ func (game *Rotating) InitTextures(tf graphics.TextureFactory) { } func (game *Rotating) Update(context ebiten.GameContext) { + const fps = 60 + game.x++ game.geometryMatrix = matrix.IdentityGeometry() 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.Rotate(float64(game.x) * 2 * math.Pi / float64(fps*10)) game.geometryMatrix.Translate(tx/2, ty/2) centerX := float64(context.ScreenWidth()) / 2 centerY := float64(context.ScreenHeight()) / 2 diff --git a/example/main.go b/example/main.go index 8ed7e4735..a5d5dbd0e 100644 --- a/example/main.go +++ b/example/main.go @@ -48,15 +48,16 @@ func main() { const screenWidth = 256 const screenHeight = 240 const screenScale = 2 + const fps = 60 const title = "Ebiten Demo" ui := cocoa.New(screenWidth, screenHeight, screenScale, title) ui.Start() ui.InitTextures(game.InitTextures) - frameTime := time.Duration(int64(time.Second) / int64(ebiten.FPS)) - tick := time.Tick(frameTime) lock := sync.Mutex{} go func() { + frameTime := time.Duration(int64(time.Second) / int64(fps)) + tick := time.Tick(frameTime) for { <-tick ui.Update(func(c ebiten.GameContext) {