added MinMoves to lvl files, added score system in game observer
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Description: test obstacles
|
||||
MinMoves: 2
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Description: test obstacles
|
||||
MinMoves: 14
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Description: find the fruit
|
||||
MinMoves: 7
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
Description: win
|
||||
MinMoves: 5
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
|
||||
########
|
||||
#v o #
|
||||
# S<# #
|
||||
# o <o#
|
||||
#v S # #
|
||||
# #### #
|
||||
|
||||
|
||||
# #### #
|
||||
# #
|
||||
#> ^#
|
||||
# ^#
|
||||
########
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Description: use multiple players
|
||||
MinMoves: 4
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Description: space
|
||||
MinMoves: 3
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
@@ -204,6 +205,7 @@ type RawLevel struct {
|
||||
Description string
|
||||
Background *ebiten.Image
|
||||
Data []byte
|
||||
MinMoves int
|
||||
}
|
||||
|
||||
func InitTiles() TileRegistry {
|
||||
@@ -272,6 +274,7 @@ func ParseRawLevel(dir string, levelfile fs.DirEntry) RawLevel {
|
||||
des := ""
|
||||
background := &ebiten.Image{}
|
||||
data := []byte{}
|
||||
minmoves := 0
|
||||
|
||||
scanner := bufio.NewScanner(fd)
|
||||
for scanner.Scan() {
|
||||
@@ -292,6 +295,12 @@ func ParseRawLevel(dir string, levelfile fs.DirEntry) RawLevel {
|
||||
case strings.Contains(line, "Description:"):
|
||||
haveit := strings.Split(line, ": ")
|
||||
des = haveit[1]
|
||||
case strings.Contains(line, "MinMoves:"):
|
||||
haveit := strings.Split(line, ": ")
|
||||
minmoves, err = strconv.Atoi(haveit[1])
|
||||
if err != nil {
|
||||
log.Fatal("Failed to convert MinMoves to int: %w", err)
|
||||
}
|
||||
default:
|
||||
// all other non-empty and non-equalsign lines are
|
||||
// level definition matrix data, merge thes into data
|
||||
@@ -304,5 +313,6 @@ func ParseRawLevel(dir string, levelfile fs.DirEntry) RawLevel {
|
||||
Data: data,
|
||||
Background: background,
|
||||
Description: des,
|
||||
MinMoves: minmoves,
|
||||
}
|
||||
}
|
||||
|
||||
BIN
assets/sprites/background-popup-wide.png
Normal file
BIN
assets/sprites/background-popup-wide.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user