Documentation ¶
Index ¶
- Constants
- Variables
- func FetchTileset(ts *tmx.TileSet) error
- func ParseImageSrcByOrientation(defaultSrc string, properties map[string]string) (map[m.Orientation]string, error)
- func ResolveImage(transform, orientation m.Orientation, defaultImageSrc string, ...) (string, m.Orientation)
- type CheckpointEdge
- type CheckpointLocation
- type CheckpointLocations
- type Contents
- type EntityID
- type JSONCheckpointGraph
- type JSONCheckpointObject
- type Level
- type LevelTile
- type PersistentState
- type SaveGame
- type SaveGameData
- type Spawnable
- type Tile
- type VisibilityFlags
- type WarpZone
Constants ¶
const (
// TileSize is the size of each tile graphics.
TileSize = 16
)
Variables ¶
Functions ¶
func FetchTileset ¶
func ParseImageSrcByOrientation ¶
func ParseImageSrcByOrientation(defaultSrc string, properties map[string]string) (map[m.Orientation]string, error)
ParseImageSrcByOrientation parses the imgSrcByOrientation map.
func ResolveImage ¶
func ResolveImage(transform, orientation m.Orientation, defaultImageSrc string, imageSrcByOrientation map[m.Orientation]string) (string, m.Orientation)
ResolveImage applies the given imageSrcByOrientation map.
Types ¶
type CheckpointEdge ¶
type CheckpointLocation ¶
type CheckpointLocation struct { MapPos m.Pos NextByDir map[m.Delta]CheckpointEdge // Note: two sided. NextDeadEnds []CheckpointEdge }
type CheckpointLocations ¶
type CheckpointLocations struct { Locs map[string]*CheckpointLocation Rect m.Rect }
type Contents ¶
type Contents int
Contents indicates what kind of tiles/objects we want to hit.
const ( NoContents Contents = 0 OpaqueContents Contents = 1 PlayerSolidContents Contents = 2 ObjectSolidContents Contents = 4 SolidContents Contents = PlayerSolidContents | ObjectSolidContents )
func (Contents) ObjectSolid ¶
func (Contents) PlayerSolid ¶
type EntityID ¶
type EntityID int
EntityID represents an unique ID of an entity.
const InvalidEntityID EntityID = 0
InvalidEntityID is an ID that cannot be used in Tiled. Tiled's first entity has ID 1.
type JSONCheckpointGraph ¶
type JSONCheckpointGraph struct {
Objects []JSONCheckpointObject
}
type JSONCheckpointObject ¶
type Level ¶
type Level struct { Player *Spawnable Checkpoints map[string]*Spawnable TnihSignsByCheckpoint map[string][]*Spawnable CheckpointLocations *CheckpointLocations SaveGameVersion int CreditsMusic string Hash uint64 // contains filtered or unexported fields }
Level is a parsed form of a loaded level.
func (*Level) ForEachTile ¶
ForEachTile iterates over all tiles in the level.
func (*Level) LoadCheckpointLocations ¶
func (l *Level) LoadCheckpointLocations(filename string) (*CheckpointLocations, error)
func (*Level) LoadGame ¶
LoadGame loads the given SaveGame into the map. Note that when this returns an error, the SaveGame might have been partially loaded and the world may need to be reset.
type PersistentState ¶
PersistentState is how entities retain values across loading/unloading and in save games.
type SaveGame ¶
type SaveGame struct { SaveGameData Hash uint64 }
SaveGame is the data structure we save game state with. It contains all needed (in addition to loading the level) to reset to the last visited checkpoint.
type SaveGameData ¶
type SaveGameData struct { State map[EntityID]PersistentState GameVersion string `hash:"-"` LevelVersion int LevelHash uint64 }
SaveGameData is a not-yet-hashed SaveGame.
type Spawnable ¶
type Spawnable struct { ID EntityID // Type. EntityType string // Location. LevelPos m.Pos RectInTile m.Rect Orientation m.Orientation // Other properties. Properties map[string]string // Persistent entity state, if any, shall be kept in this map. PersistentState map[string]string `hash:"-"` }
A Spawnable is a blueprint to create an Entity.
type Tile ¶
type Tile struct { // Info needed for gameplay. Contents Contents Spawnables []*Spawnable // NOTE: not adjusted for transform! // Info needed for loading more tiles. LevelPos m.Pos Transform m.Orientation VisibilityFlags VisibilityFlags // Info needed for rendering. Orientation m.Orientation ImageSrc string // Debug info. LoadedFromNeighbor m.Pos // contains filtered or unexported fields }
A Tile is a single game tile.
func (*Tile) ResolveImage ¶
func (t *Tile) ResolveImage()
ResolveImage applies imageSrcByOrientation data to Image, and possibly changes Orientation when it did.
type VisibilityFlags ¶
type VisibilityFlags int
const ( FrameVis VisibilityFlags = 1 TracedVis VisibilityFlags = 2 )
type WarpZone ¶
type WarpZone struct { Name string Invert bool Switchable bool PrevTile m.Pos ToTile m.Pos Transform m.Orientation }
WarpZone represents a warp tile. Whenever anything enters this tile, it gets moved to "to" and the direction transformed by "transform". For the game to work, every warpZone must be paired with an exact opposite elsewhere. This is ensured at load time. Warpzones can be temporarily toggled by name; this state is lost on checkpoint restore.