Remove GameContext.Terminate()

This commit is contained in:
Hajime Hoshi 2013-10-13 17:43:56 +09:00
parent c396d5561d
commit 54893c3031
4 changed files with 1 additions and 39 deletions

View File

@ -18,7 +18,6 @@ type GameContext interface {
ScreenWidth() int
ScreenHeight() int
InputState() InputState
Terminate()
}
type InputState struct {

View File

@ -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) {
}

View File

@ -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()
}

View File

@ -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
}