mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
Remove GameContext.Terminate()
This commit is contained in:
parent
c396d5561d
commit
54893c3031
@ -18,7 +18,6 @@ type GameContext interface {
|
|||||||
ScreenWidth() int
|
ScreenWidth() int
|
||||||
ScreenHeight() int
|
ScreenHeight() int
|
||||||
InputState() InputState
|
InputState() InputState
|
||||||
Terminate()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputState struct {
|
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/rects"
|
||||||
"github.com/hajimehoshi/go.ebiten/example/game/rotating"
|
"github.com/hajimehoshi/go.ebiten/example/game/rotating"
|
||||||
"github.com/hajimehoshi/go.ebiten/example/game/sprites"
|
"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"
|
"github.com/hajimehoshi/go.ebiten/ui/glut"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -36,8 +36,6 @@ func main() {
|
|||||||
game = rotating.New()
|
game = rotating.New()
|
||||||
case "sprites":
|
case "sprites":
|
||||||
game = sprites.New()
|
game = sprites.New()
|
||||||
case "terminate":
|
|
||||||
game = terminate.New()
|
|
||||||
default:
|
default:
|
||||||
game = rotating.New()
|
game = rotating.New()
|
||||||
}
|
}
|
||||||
|
@ -166,9 +166,6 @@ func Run(game ebiten.Game, screenWidth, screenHeight, screenScale int, title str
|
|||||||
case ui.updating <- game.Draw:
|
case ui.updating <- game.Draw:
|
||||||
<-ui.updated
|
<-ui.updated
|
||||||
}
|
}
|
||||||
if gameContext.terminated {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}()
|
}()
|
||||||
@ -180,7 +177,6 @@ type GameContext struct {
|
|||||||
screenWidth int
|
screenWidth int
|
||||||
screenHeight int
|
screenHeight int
|
||||||
inputState ebiten.InputState
|
inputState ebiten.InputState
|
||||||
terminated bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *GameContext) ScreenWidth() int {
|
func (context *GameContext) ScreenWidth() int {
|
||||||
@ -194,7 +190,3 @@ func (context *GameContext) ScreenHeight() int {
|
|||||||
func (context *GameContext) InputState() ebiten.InputState {
|
func (context *GameContext) InputState() ebiten.InputState {
|
||||||
return context.inputState
|
return context.inputState
|
||||||
}
|
}
|
||||||
|
|
||||||
func (context *GameContext) Terminate() {
|
|
||||||
context.terminated = true
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user