-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleveleditor.go
36 lines (28 loc) · 1015 Bytes
/
leveleditor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build !deploy
// +build !deploy
package main
import (
"fmt"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/inpututil"
"github.com/jcgraybill/it-costs-money/level"
"github.com/jcgraybill/it-costs-money/sys"
)
func levelEditor(g *Game) string {
// Live reload of level
if inpututil.IsKeyJustPressed(ebiten.Key0) {
g.level = level.New(g.level.LevelNumber)
}
// skip ahead to next spawn point
if inpututil.IsKeyJustPressed(ebiten.Key9) {
g.player.X, g.player.Y = g.level.NextSpawn(g.player.X, g.player.Y)
g.player.YVelocity = 0
}
// display current coordinates of player
xCellRune := ' '
if xCell := (g.player.X-sys.FrameWidth/2)/(sys.FrameWidth*26) + 64; xCell > 64 {
xCellRune = rune(xCell)
}
pos := fmt.Sprintf("%c%c:%d", xCellRune, rune(((g.player.X-sys.FrameWidth/2)/sys.FrameWidth)%26+65), g.player.Y/sys.FrameWidth+1)
return fmt.Sprintf("level edit mode\n[%s]0:reload 9:spawn\ntps %d fps %d", pos, int(ebiten.CurrentTPS()), int(ebiten.CurrentFPS()))
}