Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyConfigs()
- func Collides(g *Game) *ldtkgo.Tile
- func Impassible(tile *ldtkgo.Tile) bool
- func LoadImage(name string) *ebiten.Image
- func NewGame(game *Game)
- func OverlapsTiles(ts []*ldtkgo.Tile, hitbox image.Rectangle, gridSize int) *ldtkgo.Tile
- func Squishy(tile *ldtkgo.Tile) bool
- type Blackness
- type Cricket
- type CricketState
- type EmbedLoader
- type Game
- type Object
- type RenderedLayer
- type TileRenderer
- type TilesetLoader
- type WinScreen
Constants ¶
const ( JumpPressNone int = iota JumpPressLeft JumpPressRight JumpPressCancel )
JumpPress are the different jump states for controls
const LayerAuto int = 1
LayerAuto is the layer to check for auto-tile collisions
const LayerEntities int = 0
LayerEntities is the layer to use for entity positions
const LayerTile int = 2
LayerTile is the layer to check for tile collisions
Variables ¶
var BlacknessFactor int = 10
BlacknessFactor sets after how many jumps the amount of blackness that's added per jump should be doubled
var DebugMode bool = false
DebugMode sets whether to display additional debugging info on the screen during playing the game or not
var MaxPrime int = 5
MaxPrime is the maximum jump level (after division) you can prime the cricket to jump for, it avoids you jumping off the screen
var MinPrime int = 1
MinPrime is the minimum jump level (after division) you can prime the cricket to jump for, it ensures you jump somewhat even just for a short tap
var TileSquishy = []int{
9, 41, 73,
13, 45, 77,
15, 47, 79,
19, 20,
}
TileSquishy is a list of tiles you should move on top of when you them
var TilesImpassible = []int{
0, 1, 32, 64, 65,
17, 21, 81, 85,
128,
194, 256, 260, 322,
}
TilesImpassible is a list of tiles you can't pass through while jumping
var TilesWater = []int{18, 19, 20, 82, 83, 84, 114, 145, 156, 146}
TilesWater is a list of tiles that should behave like water
var VelocityDenominator int = 10
VelocityDenominator is by how much to divide the time the jump was primed to get the jump velocity
var VelocityXMultiplier int = 2
VelocityXMultiplier is by how much to multiply the Y velocity to get the velocity for the X axis, it's usually bigger
Functions ¶
func ApplyConfigs ¶
func ApplyConfigs()
ApplyConfigs overrides default values with a config file if available
func Impassible ¶
Impassible checks whether a tile is impassible (true) or passible (false)
func LoadImage ¶
func LoadImage(name string) *ebiten.Image
LoadImage loads an ebiten.Image given the name of a file in the embedded fs
func OverlapsTiles ¶
OverlapsTiles checks for collisions on a given layer This inner function is a workaround because we need to loop through both Tiles and AutoTiles in exactly the same way
Types ¶
type Cricket ¶
type Cricket struct { *Object Position image.Point Velocity image.Point Jumping bool PrimeDuration int Direction int Frame int Width int State CricketState // contains filtered or unexported fields }
Cricket is a small, jumping insect, the main character of the game
func NewCricket ¶
NewCricket returns a new Cricket object at the given position
type CricketState ¶
type CricketState int
CricketState are the different animation states a Cricket can be in
const ( // Idle is the animation state when the Cricket is not moving Idle CricketState = iota // Jumping is the animation state on the way up Jumping // Landing is the animation state on the way down Landing )
type EmbedLoader ¶
type EmbedLoader struct {
BasePath string
}
EmbedLoader is a TilesetLoader for the embedded FS
func (*EmbedLoader) LoadTileset ¶
func (l *EmbedLoader) LoadTileset(tileSetPath string) *ebiten.Image
LoadTileset loads an LDtk tileset image from the embedded FS
type Game ¶
type Game struct { Width int Height int Cricket *Cricket Wait int WaitTime int TileRenderer *TileRenderer LDTKProject *ldtkgo.Project Level int Loading bool // contains filtered or unexported fields }
Game represents the main game state
func (*Game) EntityByIdentifier ¶
EntityByIdentifier is a convenience function for the same thing in ldtkgo but defaulting to checking the Entities layer of the current level
type Object ¶
An Object is something that can be seen and positioned in the game
func NewObjectFromImage ¶
func NewObjectFromImage(img *ebiten.Image) *Object
NewObjectFromImage makes a new game Object with fields calculated from an already loaded image
type RenderedLayer ¶
type RenderedLayer struct { Image *ebiten.Image // The image that was rendered out Layer *ldtkgo.Layer // The layer used to render the image }
RenderedLayer represents an LDtk.Layer that was rendered out to an *ebiten.Image.
type TileRenderer ¶
type TileRenderer struct { Tilesets map[string]*ebiten.Image CurrentTileset string RenderedLayers []*RenderedLayer Loader TilesetLoader // Loader for the renderer; defaults to a DiskLoader instance, though this can be switched out with something else as necessary. }
TileRenderer is a struct that renders LDtk levels to *ebiten.Images.
func NewTileRenderer ¶
func NewTileRenderer(loader TilesetLoader) *TileRenderer
NewTileRenderer creates a new Renderer instance. TilesetLoader should be an instance of a struct designed to return *ebiten.Images for each Tileset requested (by path relative to the LDtk project file).
func (*TileRenderer) Render ¶
func (er *TileRenderer) Render(level *ldtkgo.Level)
Render clears, and then renders out each visible Layer in an ldtgo.Level instance.
type TilesetLoader ¶
type TilesetLoader interface {
LoadTileset(string) *ebiten.Image
}
TilesetLoader represents an interface that can be implemented to load a tileset from string, returning an *ebiten.Image.