mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
Remove ebiten.FPS
This commit is contained in:
parent
cc7b78bb9a
commit
bcb8c0d45a
@ -4,10 +4,6 @@ import (
|
||||
"github.com/hajimehoshi/go-ebiten/graphics"
|
||||
)
|
||||
|
||||
const (
|
||||
FPS = 60
|
||||
)
|
||||
|
||||
type Game interface {
|
||||
InitTextures(tf graphics.TextureFactory)
|
||||
Update(context GameContext)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user