trisoban

package
v0.0.0-...-ccd3d7d Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentLevel int

CurrentLevel this integer will determine the level you are currently on.

View Source
var TotalLevels = GetTotalLevels()

TotalLevels this integer represents the total amount of levels.

Functions

func GetTotalLevels

func GetTotalLevels() int

GetTotalLevels get total levels in lvl folder

func LoadLevel

func LoadLevel() int

LoadLevel load level from last saved lvl

func StartGame

func StartGame()

StartGame starts the game by creating a new game and adding a titlescreen.

Types

type Border

type Border struct {
	*tl.Entity
	// contains filtered or unexported fields
}

Border inherits the entity making it a drawable. It also consists of the bordercoordinates in a map.

func NewBorder

func NewBorder() *Border

NewBorder creates an entity for the border and returns a pointer to a border

func (*Border) Draw

func (border *Border) Draw(screen *tl.Screen)

Draw is a method for border that will print out the border with the given coordinates

type Coordinates

type Coordinates struct {
	X int
	Y int
}

Coordinates is used to save the X and Y coordinates of multiple entities.

type Crate

type Crate struct {
	*tl.Entity
	Coordinates
}

Crate inherits the entity making it a drawable, it also inherits the coordinates struct, and has a bool for the rachedgoal check.

func NewCrate

func NewCrate() *Crate

NewCrate creates an entity for the crate and returns a pointer to a crate

func (*Crate) CheckActivatedGoalCollision

func (crate *Crate) CheckActivatedGoalCollision(g *Goal) bool

CheckActivatedGoalCollision check if the crate is colliding with an activated goal, if so it will return true.

func (*Crate) CheckBorderCollision

func (crate *Crate) CheckBorderCollision() bool

CheckBorderCollision will check if the crate has a collision with the border. If so, this will return true.

func (*Crate) CheckCrateCollision

func (crate *Crate) CheckCrateCollision(crates []*Crate) bool

CheckCrateCollision check whether the given crate is colliding with any other crate

func (*Crate) CheckGoalCollision

func (crate *Crate) CheckGoalCollision(g *Goal) bool

CheckGoalCollision check if the crate is colliding with the goal, if so it will return true.

func (*Crate) CopyCrateSlice

func (crate *Crate) CopyCrateSlice() []*Crate

CopyCrateSlice create a duplicate of the crate entity slice

func (*Crate) Draw

func (crate *Crate) Draw(screen *tl.Screen)

Draw draws the crate given the coordinates, this will update every tick.

func (*Crate) MoveCrate

func (crate *Crate) MoveCrate(dir string, colliding bool)

MoveCrate move the crate if there is no collision, else it will take a step back(entity doesn't move)

func (*Crate) RemoveCrate

func (crate *Crate) RemoveCrate(slice []*Crate, i int) []*Crate

RemoveCrate remove a crate from the entity slice

type EntityCollection

type EntityCollection struct {
	Player *Player
	Crates []*Crate
	Goals  []*Goal
	Border *Border
}

EntityCollection collection of all entities within the game.

func NewEntityCollection

func NewEntityCollection() *EntityCollection

NewEntityCollection creates a collection of all the entities in the game

type GameCompletionScreen

type GameCompletionScreen struct {
	tl.Level
	UI            *tl.Entity
	FinalTimeText *tl.Text
	FinalTime     string
}

GameCompletionScreen is the level of the victory screen, displaying when you finish all levels.

func NewGameCompletionScreen

func NewGameCompletionScreen() *GameCompletionScreen

NewGameCompletionScreen will create a new gamecompletionscreen for when all levels are beaten.

func (*GameCompletionScreen) SaveTime

func (gs *GameCompletionScreen) SaveTime(finalTime string)

SaveTime save your collective time after beating the game.

func (*GameCompletionScreen) Tick

func (gcs *GameCompletionScreen) Tick(event tl.Event)

Tick listens to keyinput on the titlescreen, so if the enter key is pressed, the game will start.

type Gamescreen

type Gamescreen struct {
	tl.Level
	UI               *tl.Entity
	CurrentLevelText *tl.Text
	Time             *tl.Text
	Instructions     []*tl.Text
	SaveConfirmation *tl.Text
	LevelCompleted   *tl.Text
}

Gamescreen is the level for the gamescreen.

func NewGameScreen

func NewGameScreen() *Gamescreen

NewGameScreen will create a new gamescreen with the currentleveltext, instructions and the level itself and return it where it is called.

func (*Gamescreen) AddGameEntities

func (gs *Gamescreen) AddGameEntities()

AddGameEntities create all entities on the game screen and map level

func (*Gamescreen) ChangeLevel

func (gs *Gamescreen) ChangeLevel(selection string)

ChangeLevel will change the level given the player input.

func (*Gamescreen) CheckLevelCompletion

func (gs *Gamescreen) CheckLevelCompletion() bool

CheckLevelCompletion will remove the crate entity and print a text when the level is beaten.

func (*Gamescreen) MapLevel

func (gs *Gamescreen) MapLevel()

MapLevel reads from a level file and maps the coordinates for all of the entities

func (*Gamescreen) Move

func (gs *Gamescreen) Move(dir string)

Move calculate and check collisions for the current move

func (*Gamescreen) RemoveGameEntities

func (gs *Gamescreen) RemoveGameEntities()

RemoveGameEntities delete all entities on the game screen.

func (*Gamescreen) RestartLevel

func (gs *Gamescreen) RestartLevel()

RestartLevel is a function that will reset the level by setting all of the entites to their default positions.

func (*Gamescreen) SaveGame

func (gs *Gamescreen) SaveGame()

SaveGame save your current level to a file and show a confirmation.

func (*Gamescreen) Tick

func (gs *Gamescreen) Tick(event tl.Event)

Tick listens to the gamescreen input and handles it accordingly.

func (*Gamescreen) UpdateText

func (gs *Gamescreen) UpdateText()

UpdateText will update the text on the game screen. This function is called when the level is changed

type Goal

type Goal struct {
	*tl.Entity
	Coordinates
	// contains filtered or unexported fields
}

Goal inherits the entity making it a drawable, it also inherits the coordinates struct.

func NewGoal

func NewGoal() *Goal

NewGoal creates an entity for the goal and returns a pointer to a goal

func (*Goal) Draw

func (goal *Goal) Draw(screen *tl.Screen)

Draw draws the goal entity. When the goal is not yet reached, the color will be yellow(When reached it updates to green).

type Player

type Player struct {
	*tl.Entity
	Border
	Coordinates
}

Player inherits the entity making it a drawable, it also inherits the border and coordinates struct.

func NewPlayer

func NewPlayer() *Player

NewPlayer creates an entity for the player and returns a pointer to a player

func (*Player) CalculatePlayerCoordinates

func (player *Player) CalculatePlayerCoordinates(dir string) Coordinates

CalculatePlayerCoordinates calculates the coordinates from the player for current move

func (*Player) CheckActivatedGoalCollision

func (player *Player) CheckActivatedGoalCollision(g *Goal, dir string) bool

CheckActivatedGoalCollision will check if the player is colliding an activated goal.

func (*Player) CheckBorderCollision

func (player *Player) CheckBorderCollision(dir string) bool

CheckBorderCollision will check if the player is colliding with the border.

func (*Player) CheckCrateCollision

func (player *Player) CheckCrateCollision(c *Crate, dir string) bool

CheckCrateCollision will check if the player is colliding with the crate.

func (*Player) Draw

func (player *Player) Draw(screen *tl.Screen)

Draw will print the entity of the player and update it every tick. It also prints the cells for the instructions.

func (*Player) MovePlayer

func (player *Player) MovePlayer(dir string, colliding bool)

MovePlayer move the player if there is no collision, else it will take a step back(entity doesn't move)

type Stopwatch

type Stopwatch struct {
	// contains filtered or unexported fields
}

Stopwatch to keep track of your best times

func InitTimer

func InitTimer() *Stopwatch

InitTimer Initialize the timer and start it.

func (*Stopwatch) CheckpointTime

func (sw *Stopwatch) CheckpointTime() string

CheckpointTime subtract the start time of the current time and return it as a string.

func (*Stopwatch) FinishTime

func (sw *Stopwatch) FinishTime() string

FinishTime subtract the start time of the stoptime to get the total time.

func (*Stopwatch) Start

func (sw *Stopwatch) Start() *Stopwatch

Start start the timer, set starttime value and return it.

func (*Stopwatch) Stop

func (sw *Stopwatch) Stop()

Stop set the value of the stoptime to pinpoint when the timer stopped.

type Titlescreen

type Titlescreen struct {
	tl.Level
	Mainmenu   *tl.Entity
	EntityText []*tl.Text
}

Titlescreen is the level for the titlescreen.

func NewTitleScreen

func NewTitleScreen() *Titlescreen

NewTitleScreen will create a new titlescreen and read from the logo file to print out the ASCII art logo. This function will return a pointer to titlescreen.

func (*Titlescreen) Tick

func (ts *Titlescreen) Tick(event tl.Event)

Tick listens to keyinput on the titlescreen, so if the enter key is pressed, the game will start.

Jump to

Keyboard shortcuts

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