maps

package
v0.0.0-...-5198b88 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotSpecialTile = SpecialTile{"NA", coord.Coord{}, coord.Coord{}}
	Village        = Map{
		Name: "Village",
		MapTransitions: []SpecialTile{
			{"MapTransition", coord.Coord{X: 49, Y: 16, Map: 0}, coord.Coord{X: 5, Y: 6, Map: 1}},
			{"MapTransition", coord.Coord{X: 49, Y: 17, Map: 0}, coord.Coord{X: 5, Y: 6, Map: 1}},
			{"MapTransition", coord.Coord{X: 49, Y: 18, Map: 0}, coord.Coord{X: 5, Y: 6, Map: 1}},
			{"MapTransition", coord.Coord{X: 49, Y: 19, Map: 0}, coord.Coord{X: 5, Y: 6, Map: 1}},
		},
	}
	ToTheOldMine = Map{
		Name: "To the Old Mine",
		MapTransitions: []SpecialTile{
			{"MapTransition", coord.Coord{X: 0, Y: 7, Map: 1}, coord.Coord{X: 47, Y: 17, Map: 0}},
			{"MapTransition", coord.Coord{X: 0, Y: 8, Map: 1}, coord.Coord{X: 47, Y: 17, Map: 0}},
			{"MapTransition", coord.Coord{X: 0, Y: 9, Map: 1}, coord.Coord{X: 47, Y: 17, Map: 0}},
			{"MapTransition", coord.Coord{X: 0, Y: 10, Map: 1}, coord.Coord{X: 47, Y: 17, Map: 0}},
			{"MapTransition", coord.Coord{X: 63, Y: 0, Map: 1}, coord.Coord{X: 1, Y: 1, Map: 2}},
			{"MapTransition", coord.Coord{X: 63, Y: 1, Map: 1}, coord.Coord{X: 1, Y: 1, Map: 2}},
		},
	}
	TheOldMine = Map{
		Name: "The Old Mine",
		MapTransitions: []SpecialTile{
			{"MapTransition", coord.Coord{X: 0, Y: 0, Map: 2}, coord.Coord{X: 63, Y: 2, Map: 1}},
		},
	}

	// Slice containing all the maps of the game.
	AllTheMaps = []Map{Village, ToTheOldMine, TheOldMine}
)

Functions

This section is empty.

Types

type Map

type Map struct {
	Name           string
	NPCList        []*npc.Stats
	ObjectList     []*object.Object
	MapMatrix      [][]uint16
	MapTransitions []SpecialTile
	MapImage       image.Image
}

func (*Map) CheckOutOfBounds

func (currentMap *Map) CheckOutOfBounds(futurePosX, futurePosY int) bool

CheckOutOfBounds checks if x, y coordinates are out of map bounds.

func (*Map) CheckTileIsSpecial

func (currentMap *Map) CheckTileIsSpecial(posX, posY int) SpecialTile

CheckTileIsSpecial checks if, for a given map, x,y coordinates are special If so, return the SpecialTile do deal with effect.

func (*Map) CheckTileIsWalkable

func (currentMap *Map) CheckTileIsWalkable(futurePosX, futurePosY int) bool

CheckTileIsWalkable checks if, for a given map, x,y coordinates are considered walkable.

func (*Map) Copy

func (m *Map) Copy() *Map

func (*Map) FindObjectToRemove

func (currentMap *Map) FindObjectToRemove(object *object.Object) error

FindObjectToRemove loops through the currentMap ObjectList and removes object *model.Object.

func (*Map) GenerateMapImage

func (currentMap *Map) GenerateMapImage()

GenerateMapImage generates or regenerates the whole image from map tiles.

func (*Map) GetMapImageSize

func (currentMap *Map) GetMapImageSize() (float32, float32)

GetMapImageSize returns the image x and y size.

func (*Map) GetMapSize

func (currentMap *Map) GetMapSize() (mapRows, mapColumns int)

GetMapSize return number of rows and number of columns of a given map.

func (*Map) GetNPCAtPosition

func (currentMap *Map) GetNPCAtPosition(x, y int) *npc.Stats

For a given NPCsOnCurrentMap, check if NPCs are located on x,y return nil if none or pointer to npc.

func (*Map) RemoveNPC

func (currentMap *Map) RemoveNPC(npcToRemove *npc.Stats) error

For a given map, remove NPC by list id and hide CanvasImage.

type SpecialTile

type SpecialTile struct {
	Type        string
	Pos         coord.Coord
	Destination coord.Coord
}

This structure is used to specify tiles that have special meaning, like map transitions or traps.

Jump to

Keyboard shortcuts

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