mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
01a1334639
commit
9302160486
@ -193,6 +193,10 @@ func jump() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
||||||
|
return screenWidth, screenHeight
|
||||||
|
}
|
||||||
|
|
||||||
func (g *Game) Update(screen *ebiten.Image) error {
|
func (g *Game) Update(screen *ebiten.Image) error {
|
||||||
switch g.mode {
|
switch g.mode {
|
||||||
case ModeTitle:
|
case ModeTitle:
|
||||||
@ -230,11 +234,10 @@ func (g *Game) Update(screen *ebiten.Image) error {
|
|||||||
g.mode = ModeTitle
|
g.mode = ModeTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if ebiten.IsDrawingSkipped() {
|
func (g *Game) Draw(screen *ebiten.Image) {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
screen.Fill(color.RGBA{0x80, 0xa0, 0xc0, 0xff})
|
screen.Fill(color.RGBA{0x80, 0xa0, 0xc0, 0xff})
|
||||||
g.drawTiles(screen)
|
g.drawTiles(screen)
|
||||||
if g.mode != ModeTitle {
|
if g.mode != ModeTitle {
|
||||||
@ -266,7 +269,6 @@ func (g *Game) Update(screen *ebiten.Image) error {
|
|||||||
scoreStr := fmt.Sprintf("%04d", g.score())
|
scoreStr := fmt.Sprintf("%04d", g.score())
|
||||||
text.Draw(screen, scoreStr, arcadeFont, screenWidth-len(scoreStr)*fontSize, fontSize, color.White)
|
text.Draw(screen, scoreStr, arcadeFont, screenWidth-len(scoreStr)*fontSize, fontSize, color.White)
|
||||||
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.CurrentTPS()))
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *Game) pipeAt(tileX int) (tileY int, ok bool) {
|
func (g *Game) pipeAt(tileX int) (tileY int, ok bool) {
|
||||||
@ -390,8 +392,9 @@ func (g *Game) drawGopher(screen *ebiten.Image) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
g := NewGame()
|
ebiten.SetWindowSize(screenWidth, screenHeight)
|
||||||
if err := ebiten.Run(g.Update, screenWidth, screenHeight, 1, "Flappy Gopher (Ebiten Demo)"); err != nil {
|
ebiten.SetWindowTitle("Flappy Gopher (Ebiten Demo)")
|
||||||
|
if err := ebiten.RunGame(NewGame()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user