Add intro message
This commit is contained in:
parent
2f3ec2cdf2
commit
10d9b1f0ed
|
@ -20,7 +20,8 @@ func NewPlayer() gohan.Entity {
|
|||
player.AddComponent(weapon)
|
||||
|
||||
player.AddComponent(&component.Sprite{
|
||||
Image: asset.FishImage(int(level.FishParrot)),
|
||||
Image: asset.FishImage(int(level.FishParrot)),
|
||||
HorizontalFlip: true,
|
||||
})
|
||||
|
||||
player.AddComponent(&component.Rail{})
|
||||
|
|
6
main.go
6
main.go
|
@ -39,7 +39,11 @@ func main() {
|
|||
g.Exit()
|
||||
}()
|
||||
|
||||
world.StartGame()
|
||||
if world.World.Debug == 0 {
|
||||
world.SetMessage("POLLUTION... DESTRUCTION...\nTHE FISH HAVE HAD ENOUGH!\nIT'S PAYBACK TIME!\nPRESS <ENTER> TO GET REVENGE!", 144)
|
||||
} else {
|
||||
world.StartGame()
|
||||
}
|
||||
|
||||
err = ebiten.RunGame(g)
|
||||
if err != nil {
|
||||
|
|
|
@ -47,7 +47,7 @@ func (s *RenderMessageSystem) Update(_ gohan.Entity) error {
|
|||
}
|
||||
|
||||
func (s *RenderMessageSystem) Draw(_ gohan.Entity, screen *ebiten.Image) error {
|
||||
if !world.World.GameStarted || !world.World.MessageVisible {
|
||||
if !world.World.MessageVisible {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -68,23 +68,23 @@ func (s *RenderMessageSystem) drawMessage() {
|
|||
split := strings.Split(world.World.MessageText, "\n")
|
||||
width := 0
|
||||
for _, line := range split {
|
||||
lineSize := len(line) * 12
|
||||
lineSize := len(line) * 6
|
||||
if lineSize > width {
|
||||
width = lineSize
|
||||
}
|
||||
}
|
||||
height := len(split) * 32
|
||||
height := len(split) * 16
|
||||
|
||||
const padding = 8
|
||||
const padding = 4
|
||||
width, height = width+padding*2, height+padding*2
|
||||
|
||||
s.msgImg = ebiten.NewImage(width, height)
|
||||
s.msgImg.Fill(color.RGBA{17, 17, 17, 255})
|
||||
s.msgImg.Fill(color.RGBA{0, 0, 0, 255})
|
||||
|
||||
s.tmpImg.Clear()
|
||||
s.tmpImg = ebiten.NewImage(width*2, height*2)
|
||||
s.op.GeoM.Reset()
|
||||
s.op.GeoM.Scale(2, 2)
|
||||
s.op.GeoM.Scale(1, 1)
|
||||
s.op.GeoM.Translate(float64(padding), float64(padding))
|
||||
ebitenutil.DebugPrint(s.tmpImg, world.World.MessageText)
|
||||
s.msgImg.DrawImage(s.tmpImg, s.op)
|
||||
|
|
|
@ -97,7 +97,9 @@ func Reset() {
|
|||
e.Remove()
|
||||
}
|
||||
|
||||
World.MessageVisible = false
|
||||
if World.GameStarted {
|
||||
World.MessageVisible = false
|
||||
}
|
||||
World.FirstSectionB = false
|
||||
World.Player = 0
|
||||
World.Score = 0
|
||||
|
@ -156,6 +158,9 @@ func StartGame() {
|
|||
if !World.StartMuted {
|
||||
asset.SoundMusic.Play()
|
||||
}
|
||||
|
||||
World.MessageVisible = false
|
||||
World.MessageUpdated = false
|
||||
}
|
||||
|
||||
func SetMessage(message string, duration int) {
|
||||
|
@ -193,7 +198,6 @@ func MaxCreeps() int {
|
|||
level := World.Tick / (144 * levelUpSeconds)
|
||||
|
||||
maxCreeps := minCreeps + math.Pow(2, float64(level)/4)
|
||||
log.Println("level", level, maxCreeps)
|
||||
return int(maxCreeps)
|
||||
}
|
||||
|
||||
|
@ -202,7 +206,6 @@ func NeededKills() int {
|
|||
level := int(World.Fish)
|
||||
|
||||
maxCreeps := minCreeps + level*7
|
||||
log.Println("need creep", level, maxCreeps)
|
||||
return int(maxCreeps)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue