Documentation ¶
Index ¶
- Constants
- Variables
- func FetchTileset(ts *tmx.TileSet) error
- func ParseImageSrcByOrientation(defaultSrc string, properties propmap.Map) (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
- func (l *Level) Clone() *Level
- func (l *Level) ForEachTile(f func(pos m.Pos, t *LevelTile))
- func (l *Level) LoadCheckpointLocations(filename string) (*CheckpointLocations, error)
- func (l *Level) LoadGame(save *SaveGame) error
- func (l *Level) SaveGame() (*SaveGame, error)
- func (l *Level) Tile(pos m.Pos) *LevelTile
- func (l *Level) VerifyHash() error
- type LevelTile
- type Loader
- type PersistentState
- type SaveGame
- type SaveGameData
- type SaveGameDataV1
- type Spawnable
- type SpawnableProps
- 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 propmap.Map) (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 AllContents Contents = OpaqueContents | SolidContents )
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 CheckpointLocationsHash uint64 SaveGameVersion int CreditsMusic string Hash uint64 `hash:"-"` // contains filtered or unexported fields }
Level is a parsed form of a loaded level.
func (*Level) Clone ¶
Clone clones the given Level to a new Level struct sharing no persistent state data.
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.
func (*Level) VerifyHash ¶
VerifyHash returns an error if the level hash changed.
type Loader ¶ added in v1.0.112
type Loader struct {
// contains filtered or unexported fields
}
func (*Loader) LoadStepwise ¶ added in v1.0.112
LoadStepwise loads a level in steps.
func (*Loader) SkipCheckpointLocations ¶ added in v1.0.112
func (*Loader) SkipComparingCheckpointLocations ¶ added in v1.2.217
type PersistentState ¶
PersistentState is how entities retain values across loading/unloading and in save games.
type SaveGame ¶
type SaveGame struct { SaveGameDataV1 InfoHash uint64 StateHash uint64 // Legacy hash for v0 save games. Hash uint64 `json:",omitempty"` }
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. Separate hashes govern the info parts and the state itself so demo regression testing can work across version changes.
type SaveGameData ¶
type SaveGameData struct { State map[EntityID]PersistentState LevelVersion int LevelHash uint64 }
SaveGameData is a not-yet-hashed SaveGame.
type SaveGameDataV1 ¶
type SaveGameDataV1 struct { State map[EntityID]PersistentState `hash:"-"` GameVersion string LevelVersion int LevelHash uint64 }
SaveGameDataV1 is a not-yet-hashed SaveGame.
type Spawnable ¶
type Spawnable struct { SpawnableProps // The ID of the entity in the map. ID EntityID // Location. LevelPos m.Pos RectInTile m.Rect }
A Spawnable is a blueprint to create an Entity in a level.
type SpawnableProps ¶ added in v1.0.140
type SpawnableProps struct { // Type. EntityType string // Orientation. Orientation m.Orientation // Other properties. Properties propmap.Map // Persistent entity state, if any, shall be kept in this map. PersistentState PersistentState `hash:"-"` // SpawnTilesGrowth is how much extra pixels around the entity to consider // for spawning. SpawnTilesGrowth m.Delta }
A SpawnableProps is a blueprint to create an Entity but without its position.
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.