added primary and secondary player mode
This commit is contained in:
17
assets/levels/04-mayhem.lvl
Normal file
17
assets/levels/04-mayhem.lvl
Normal file
@@ -0,0 +1,17 @@
|
||||
Description: use multiple players
|
||||
Background: background-lila
|
||||
|
||||
|
||||
|
||||
|
||||
##########
|
||||
# v#
|
||||
# #
|
||||
#S s#
|
||||
# #
|
||||
#^ #
|
||||
##########
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
BIN
assets/sprites/sphere-blue-secondary.png
Normal file
BIN
assets/sprites/sphere-blue-secondary.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user