added collectibles support

This commit is contained in:
2024-02-07 18:01:58 +01:00
parent ce7fcd038a
commit a0b40139c7
7 changed files with 116 additions and 53 deletions

View File

@@ -9,9 +9,9 @@ Background: background-orange
# ######## ###
#
############ #
# # #
# o # #
# # ######## #
# #
# # o
# ############

View File

@@ -20,13 +20,14 @@ var Tiles = InitTiles()
// Tile: contains image, identifier (as used in level data) and
// additional properties
type Tile struct {
Id byte
Sprite *ebiten.Image
Class string
Solid bool
Player bool
Renderable bool
Velocity bool
Id byte
Sprite *ebiten.Image
Class string
Solid bool
Player bool
Renderable bool
Velocity bool
Collectible bool
}
func NewTilePlayer() *Tile {
@@ -50,6 +51,17 @@ func NewTileBlock(class string) *Tile {
}
}
func NewTileCollectible(class string) *Tile {
return &Tile{
Id: 'o',
Sprite: Assets[class],
Class: class,
Solid: false,
Renderable: true,
Collectible: true,
}
}
// used to map level data bytes to actual tiles
type TileRegistry map[byte]*Tile
@@ -77,6 +89,7 @@ func InitTiles() TileRegistry {
' ': {Id: ' ', Class: "floor", Renderable: false},
'#': NewTileBlock("block-grey32"),
'S': NewTilePlayer(),
'o': NewTileCollectible("collectible-orange"),
}
}