mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Rename TPS -> MaxTPS
This commit is contained in:
parent
eadbabffd9
commit
e99f2f9f69
@ -51,7 +51,7 @@ func init() {
|
||||
}
|
||||
|
||||
func (r *recorder) delay() int {
|
||||
delay := 100 * r.skips / ebiten.TPS()
|
||||
delay := 100 * r.skips / ebiten.MaxTPS()
|
||||
if delay < 2 {
|
||||
return 2
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ var (
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
count++
|
||||
count %= ebiten.TPS() * 10
|
||||
count %= ebiten.MaxTPS() * 10
|
||||
diff := float64(count) * 0.2
|
||||
switch {
|
||||
case 480 < count:
|
||||
|
@ -66,7 +66,7 @@ func (s *GamepadScene) Update(state *GameState) error {
|
||||
if state.Input.gamepadConfig.Scan(gamepadID, b) {
|
||||
s.currentIndex++
|
||||
if s.currentIndex == len(virtualGamepadButtons) {
|
||||
s.countAfterSetting = ebiten.TPS()
|
||||
s.countAfterSetting = ebiten.MaxTPS()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -242,7 +242,7 @@ func (s *GameScene) Update(state *GameState) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
maxLandingCount := ebiten.TPS()
|
||||
maxLandingCount := ebiten.MaxTPS()
|
||||
if s.currentPiece == nil {
|
||||
s.initCurrentPiece(s.choosePiece())
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func init() {
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
space.Step(1.0 / float64(ebiten.TPS()))
|
||||
space.Step(1.0 / float64(ebiten.MaxTPS()))
|
||||
|
||||
if ebiten.IsDrawingSkipped() {
|
||||
return nil
|
||||
|
@ -117,7 +117,7 @@ func init() {
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
// Change the text color for each second.
|
||||
if counter%ebiten.TPS() == 0 {
|
||||
if counter%ebiten.MaxTPS() == 0 {
|
||||
kanjiText = []rune{}
|
||||
for j := 0; j < 4; j++ {
|
||||
for i := 0; i < 8; i++ {
|
||||
|
@ -66,7 +66,7 @@ func paint(canvas *ebiten.Image, x, y int) {
|
||||
op.GeoM.Translate(float64(x), float64(y))
|
||||
// Scale the color and rotate the hue so that colors vary on each frame.
|
||||
op.ColorM.Scale(1.0, 0.50, 0.125, 1.0)
|
||||
tps := ebiten.TPS()
|
||||
tps := ebiten.MaxTPS()
|
||||
theta := 2.0 * math.Pi * float64(count%tps) / float64(tps)
|
||||
op.ColorM.RotateHue(theta)
|
||||
canvas.DrawImage(brushImage, op)
|
||||
|
@ -119,7 +119,7 @@ func playNote(scoreIndex int) rune {
|
||||
}
|
||||
|
||||
const vol = 1.0 / 16.0
|
||||
size := 30 * sampleRate / ebiten.TPS()
|
||||
size := 30 * sampleRate / ebiten.MaxTPS()
|
||||
l := make([]int16, size)
|
||||
r := make([]int16, size)
|
||||
square(l, vol, freq, 0.25)
|
||||
|
@ -87,7 +87,7 @@ func update(screen *ebiten.Image) error {
|
||||
runnableInBackground := ebiten.IsRunnableInBackground()
|
||||
cursorVisible := ebiten.IsCursorVisible()
|
||||
vsyncEnabled := ebiten.IsVsyncEnabled()
|
||||
tps := ebiten.TPS()
|
||||
tps := ebiten.MaxTPS()
|
||||
|
||||
if inpututil.IsKeyJustPressed(ebiten.KeyUp) {
|
||||
screenHeight += d
|
||||
@ -176,8 +176,8 @@ func update(screen *ebiten.Image) error {
|
||||
|
||||
x, y := ebiten.CursorPosition()
|
||||
tpsStr := "Uncapped"
|
||||
if tps := ebiten.TPS(); tps != ebiten.UncappedTPS {
|
||||
tpsStr = fmt.Sprintf("%d", tps)
|
||||
if maxTPS := ebiten.MaxTPS(); maxTPS != ebiten.UncappedTPS {
|
||||
tpsStr = fmt.Sprintf("%d", maxTPS)
|
||||
}
|
||||
msg := fmt.Sprintf(`Press arrow keys to change the window size
|
||||
Press S key to change the window scale
|
||||
|
@ -82,7 +82,7 @@ func (c *graphicsContext) initializeIfNeeded() error {
|
||||
}
|
||||
|
||||
func (c *graphicsContext) Update(afterFrameUpdate func()) error {
|
||||
tps := int(TPS())
|
||||
tps := int(MaxTPS())
|
||||
updateCount := clock.Update(tps)
|
||||
if tps == UncappedTPS {
|
||||
updateCount = 1
|
||||
|
14
run.go
14
run.go
@ -48,11 +48,11 @@ func CurrentFPS() float64 {
|
||||
|
||||
var (
|
||||
isDrawingSkipped = int32(0)
|
||||
currentTPS = int32(0)
|
||||
currentMaxTPS = int32(0)
|
||||
)
|
||||
|
||||
func init() {
|
||||
atomic.StoreInt32(¤tTPS, DefaultTPS)
|
||||
atomic.StoreInt32(¤tMaxTPS, DefaultTPS)
|
||||
}
|
||||
|
||||
func setDrawingSkipped(skipped bool) {
|
||||
@ -557,11 +557,11 @@ func SetVsyncEnabled(enabled bool) {
|
||||
ui.SetVsyncEnabled(enabled)
|
||||
}
|
||||
|
||||
// TPS returns the current TPS.
|
||||
// MaxTPS returns the current maximum TPS.
|
||||
//
|
||||
// TPS is concurrent-safe.
|
||||
func TPS() int {
|
||||
return int(atomic.LoadInt32(¤tTPS))
|
||||
// MaxTPS is concurrent-safe.
|
||||
func MaxTPS() int {
|
||||
return int(atomic.LoadInt32(¤tMaxTPS))
|
||||
}
|
||||
|
||||
// UncappedTPS is a special TPS value that means the game doesn't have limitation on TPS.
|
||||
@ -579,5 +579,5 @@ func SetMaxTPS(tps int) {
|
||||
if tps < 0 && tps != UncappedTPS {
|
||||
panic("ebiten: tps must be >= 0 or UncappedTPS")
|
||||
}
|
||||
atomic.StoreInt32(¤tTPS, int32(tps))
|
||||
atomic.StoreInt32(¤tMaxTPS, int32(tps))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user