65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"image/color"
|
|
c "loading/character"
|
|
"loading/objects"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
"github.com/hajimehoshi/ebiten/v2/text"
|
|
)
|
|
|
|
// Game implements ebiten.Game interface.
|
|
type Game struct {
|
|
counter int
|
|
player c.Character
|
|
enemies []c.Character
|
|
keys []ebiten.Key
|
|
bobbles []objects.Bobble
|
|
}
|
|
|
|
// Layout takes the outside size (e.g., the window size) and returns the (logical) screen size.
|
|
// If you don't have to adjust the screen size with the outside size, just return a fixed size.
|
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
|
return 800, 600
|
|
}
|
|
|
|
// Draw draws the game screen.
|
|
// Draw is called every frame (typically 1/60[s] for 60Hz display).
|
|
func (g *Game) Draw(screen *ebiten.Image) {
|
|
dst := screen
|
|
dst.Fill(color.RGBA{0x28, 0x28, 0x28, 0xff})
|
|
|
|
// render the info text
|
|
text.Draw(dst, bsofttext, mplusNormalFont, 20, 40, color.White)
|
|
|
|
//g.DrawChase(dst)
|
|
//g.DrawLoading(dst)
|
|
g.DrawBobbles(dst)
|
|
}
|
|
|
|
func (g *Game) DrawBobbles(image *ebiten.Image) {
|
|
//identifier
|
|
text.Draw(image, bobblesInfo, mplusTinyFont, 20, 60, color.White)
|
|
|
|
//light up the bobbles
|
|
for i := 0; i < len(g.bobbles); i++ {
|
|
DrawBobble(g.bobbles[i], image)
|
|
}
|
|
}
|
|
|
|
func (g *Game) DrawChase(image *ebiten.Image) {
|
|
|
|
//identifier
|
|
text.Draw(image, sceneInfo, mplusTinyFont, 20, 60, color.White)
|
|
|
|
//draw the enemies first
|
|
for i := 0; i < len(g.enemies); i++ {
|
|
DrawCharacter(g.enemies[i], image)
|
|
}
|
|
|
|
//followed by the player character
|
|
DrawCharacter(g.player, image)
|
|
|
|
}
|