added primary and secondary player mode

This commit is contained in:
2024-02-22 19:40:49 +01:00
parent 308f335cd1
commit c93070883a
12 changed files with 174 additions and 10 deletions

View File

@@ -0,0 +1,17 @@
Description: use multiple players
Background: background-lila
##########
# v#
# #
#S s#
# #
#^ #
##########

View File

@@ -27,6 +27,7 @@ type Tile struct {
Class string
Solid bool
Player bool
IsPrimary bool
Renderable bool
Velocity bool
Collectible bool
@@ -38,15 +39,32 @@ type Tile struct {
Direction int // obstacles
}
func NewTilePlayer() *Tile {
return &Tile{
const (
Primary bool = true
Secondary bool = false
)
func NewTilePlayer(isprimary bool) *Tile {
tile := &Tile{
Id: 'S',
Sprite: Assets["sphere-blue"],
Class: "sphere",
Renderable: true,
Player: true,
Velocity: true,
IsPrimary: isprimary,
}
switch isprimary {
case Primary:
tile.Sprite = Assets["sphere-blue"]
case Secondary:
tile.Sprite = Assets["sphere-blue-secondary"]
tile.Id = 's'
}
// primary sprite is always the first one
tile.Tiles = []*ebiten.Image{Assets["sphere-blue"], Assets["sphere-blue-secondary"]}
return tile
}
func NewTileBlock(class string) *Tile {
@@ -148,7 +166,8 @@ func InitTiles() TileRegistry {
' ': {Id: ' ', Class: "floor", Renderable: false},
'#': NewTileBlock("block-grey32"),
'B': NewTileBlock("block-orange-32"),
'S': NewTilePlayer(),
'S': NewTilePlayer(Primary),
's': NewTilePlayer(Secondary),
'o': NewTileCollectible("collectible-orange"),
'+': NewTileObstacle("obstacle-star", config.All),
'^': NewTileObstacle("obstacle-north", config.North),

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB