mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Remove GameContext.Terminate()
This commit is contained in:
parent
c396d5561d
commit
54893c3031
@ -18,7 +18,6 @@ type GameContext interface {
|
||||
ScreenWidth() int
|
||||
ScreenHeight() int
|
||||
InputState() InputState
|
||||
Terminate()
|
||||
}
|
||||
|
||||
type InputState struct {
|
||||
|
@ -1,27 +0,0 @@
|
||||
package terminate
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/go.ebiten"
|
||||
"github.com/hajimehoshi/go.ebiten/graphics"
|
||||
)
|
||||
|
||||
type Terminate struct {
|
||||
life int
|
||||
}
|
||||
|
||||
func New() *Terminate {
|
||||
return &Terminate{60}
|
||||
}
|
||||
|
||||
func (game *Terminate) Init(tf graphics.TextureFactory) {
|
||||
}
|
||||
|
||||
func (game *Terminate) Update(context ebiten.GameContext) {
|
||||
game.life--
|
||||
if game.life <= 0 {
|
||||
context.Terminate()
|
||||
}
|
||||
}
|
||||
|
||||
func (game *Terminate) Draw(context graphics.Context) {
|
||||
}
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/hajimehoshi/go.ebiten/example/game/rects"
|
||||
"github.com/hajimehoshi/go.ebiten/example/game/rotating"
|
||||
"github.com/hajimehoshi/go.ebiten/example/game/sprites"
|
||||
"github.com/hajimehoshi/go.ebiten/example/game/terminate"
|
||||
_ "github.com/hajimehoshi/go.ebiten/ui/cocoa"
|
||||
"github.com/hajimehoshi/go.ebiten/ui/glut"
|
||||
"os"
|
||||
"runtime"
|
||||
@ -36,8 +36,6 @@ func main() {
|
||||
game = rotating.New()
|
||||
case "sprites":
|
||||
game = sprites.New()
|
||||
case "terminate":
|
||||
game = terminate.New()
|
||||
default:
|
||||
game = rotating.New()
|
||||
}
|
||||
|
@ -166,9 +166,6 @@ func Run(game ebiten.Game, screenWidth, screenHeight, screenScale int, title str
|
||||
case ui.updating <- game.Draw:
|
||||
<-ui.updated
|
||||
}
|
||||
if gameContext.terminated {
|
||||
break
|
||||
}
|
||||
}
|
||||
os.Exit(0)
|
||||
}()
|
||||
@ -180,7 +177,6 @@ type GameContext struct {
|
||||
screenWidth int
|
||||
screenHeight int
|
||||
inputState ebiten.InputState
|
||||
terminated bool
|
||||
}
|
||||
|
||||
func (context *GameContext) ScreenWidth() int {
|
||||
@ -194,7 +190,3 @@ func (context *GameContext) ScreenHeight() int {
|
||||
func (context *GameContext) InputState() ebiten.InputState {
|
||||
return context.inputState
|
||||
}
|
||||
|
||||
func (context *GameContext) Terminate() {
|
||||
context.terminated = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user