resources

package
v0.0.0-...-e9d204a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MoveUpAction is the action for moving up
	MoveUpAction = "MoveUp"
	// MoveUpFastAction is the action for moving up fast
	MoveUpFastAction = "MoveUpFast"

	// MoveDownAction is the action for moving down
	MoveDownAction = "MoveDown"
	// MoveDownFastAction is the action for moving down fast
	MoveDownFastAction = "MoveDownFast"

	// MoveLeftAction is the action for moving left
	MoveLeftAction = "MoveLeft"
	// MoveLeftFastAction is the action for moving left fast
	MoveLeftFastAction = "MoveLeftFast"

	// MoveRightAction is the action for moving right
	MoveRightAction = "MoveRight"
	// MoveRightFastAction is the action for moving right fast
	MoveRightFastAction = "MoveRightFast"

	// PreviousLevelAction is the action for switching to the previous level
	PreviousLevelAction = "PreviousLevel"
	// PreviousLevelFastAction is the action for switching fast to the previous level
	PreviousLevelFastAction = "PreviousLevelFast"

	// NextLevelAction is the action for switching to the next level
	NextLevelAction = "NextLevel"
	// NextLevelFastAction is the action for switching fast to the next level
	NextLevelFastAction = "NextLevelFast"

	// UndoAction is the action for undoing the last move
	UndoAction = "Undo"
	// UndoFastAction is the action for undoing the last move fast
	UndoFastAction = "UndoFast"

	// RestartAction is the action for restarting the level
	RestartAction = "Restart"

	// SaveAction is the action for saving the level
	SaveAction = "Save"

	// GoToLevelAction is the action for switching to a specific level
	GoToLevelAction = "GoToLevel"

	// NextStepSolutionAction is the action for playing the next solution step
	NextStepSolutionAction = "NextStepSolution"
	// NextStepSolutionFastAction is the action for playing the next solution step fast
	NextStepSolutionFastAction = "NextStepSolutionFast"

	// PreviousStepSolutionAction is the action for undoing to the previous solution step
	PreviousStepSolutionAction = "PreviousStepSolution"
	// PreviousStepSolutionFastAction is the action for undoing fast to the previous solution step
	PreviousStepSolutionFastAction = "PreviousStepSolutionFast"
)
View Source
const (
	TilePlayer = gloader.TilePlayer
	TileBox    = gloader.TileBox
	TileGoal   = gloader.TileGoal
	TileWall   = gloader.TileWall
	TileEmpty  = gloader.TileEmpty
)

List of game tiles

View Source
const MaxAuthorLen = 6

MaxAuthorLen is the maximum highscore author length

Variables

View Source
var RegexpHighscoreForbiddenChars = regexp.MustCompile("[[:^alnum:]]")

RegexpHighscoreForbiddenChars contains the list of forbidden characters is a highscore author

Functions

func EncodeMovements

func EncodeMovements(movements []MovementType) string

EncodeMovements encodes movements

func GetLastPackageName

func GetLastPackageName() string

GetLastPackageName gets the last package name

func InitLevel

func InitLevel(world w.World, levelNum int)

InitLevel inits level

func LoadSave

func LoadSave(world w.World)

LoadSave loads save for a level

func Move

func Move(world w.World, movements ...MovementType)

Move executes a series of movements

func NormalizeHighScores

func NormalizeHighScores(t HighscoreTable)

NormalizeHighScores normalizes highscores

func SaveLevel

func SaveLevel(world w.World)

SaveLevel saves level

func Undo

func Undo(world w.World)

Undo undoes the last move

func UpdateGameLayout

func UpdateGameLayout(world w.World, gridLayout *GridLayout) (int, int)

UpdateGameLayout updates game layout

Types

type EncodedSaveConfig

type EncodedSaveConfig map[string]interface{}

EncodedSaveConfig contains the encoded save configuration

func (*EncodedSaveConfig) Decode

func (esc *EncodedSaveConfig) Decode() (sc SaveConfig, err error)

Decode decodes the encoded save configuration

type Game

type Game struct {
	StateEvent StateEvent
	Package    PackageData
	Level      Level
	GridLayout GridLayout
	SaveConfig SaveConfig
}

Game contains game resources

type GamePrefabs

type GamePrefabs struct {
	LevelInfo   loader.EntityComponentList
	BoxInfo     loader.EntityComponentList
	StepInfo    loader.EntityComponentList
	PackageInfo loader.EntityComponentList
}

GamePrefabs contains game prefabs

type GridLayout

type GridLayout struct {
	Width  int
	Height int
}

GridLayout is the grid layout

type Highscore

type Highscore struct {
	Author    string
	Movements string
}

Highscore is a game highscore

type HighscoreTable

type HighscoreTable = map[string]Highscore

type Level

type Level struct {
	CurrentNum int
	Grid       gutils.Vec2d[Tile]
	Movements  []MovementType
	Modified   bool
}

Level is a game level

type MenuPrefabs struct {
	MainMenu          loader.EntityComponentList
	ChoosePackageMenu loader.EntityComponentList
	PauseMenu         loader.EntityComponentList
	LevelCompleteMenu loader.EntityComponentList
	HighscoresMenu    loader.EntityComponentList
	SolutionsMenu     loader.EntityComponentList
}

MenuPrefabs contains menu prefabs

type MovementType

type MovementType uint8

MovementType is a movement type

const (
	MovementUp MovementType = iota
	MovementDown
	MovementLeft
	MovementRight
	MovementUpPush
	MovementDownPush
	MovementLeftPush
	MovementRightPush
)

List of movements

func DecodeMovements

func DecodeMovements(encodedMovements string) []MovementType

DecodeMovements decodes movements

func GetPushMovement

func GetPushMovement(m MovementType) MovementType

GetPushMovement returns push movement

func GetSimpleMovement

func GetSimpleMovement(m MovementType) MovementType

GetSimpleMovement returns simple movement

type PackageData

type PackageData = gloader.PackageData

PackageData contains level package data

type Prefabs

type Prefabs struct {
	Menu MenuPrefabs
	Game GamePrefabs
}

Prefabs contains game prefabs

type SaveConfig

type SaveConfig struct {
	CurrentLevel   int
	LevelMovements map[string]string
}

SaveConfig contains the save configuration

func EmptySaveConfig

func EmptySaveConfig() SaveConfig

EmptySaveConfig returns an empty save configuration

func (*SaveConfig) Encode

func (sc *SaveConfig) Encode() EncodedSaveConfig

Encode encodes the save configuration

type StateEvent

type StateEvent int

StateEvent is an event for game progression

const (
	StateEventNone StateEvent = iota
	StateEventLevelComplete
)

List of game progression events

type Tile

type Tile = gloader.Tile

Tile is a game tile

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL