obstacle collission added, but not working yet
This commit is contained in:
@@ -5,13 +5,13 @@ Background: background-lila
|
||||
|
||||
|
||||
########
|
||||
# o # #
|
||||
# S # #
|
||||
#v o #
|
||||
# S<# #
|
||||
# #### #
|
||||
|
||||
|
||||
# #### #
|
||||
# #
|
||||
# #
|
||||
#> ^#
|
||||
########
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ import (
|
||||
"io/fs"
|
||||
"log"
|
||||
"log/slog"
|
||||
"openquell/config"
|
||||
"openquell/util"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/v2"
|
||||
@@ -28,9 +30,10 @@ type Tile struct {
|
||||
Renderable bool
|
||||
Velocity bool
|
||||
Collectible bool
|
||||
Obstacle bool
|
||||
Particle int // -1=unused, 0-3 = show image of slice
|
||||
Particles []*ebiten.Image
|
||||
Obstacle bool
|
||||
Direction int // obstacles
|
||||
}
|
||||
|
||||
func NewTilePlayer() *Tile {
|
||||
@@ -65,7 +68,7 @@ func NewTileCollectible(class string) *Tile {
|
||||
}
|
||||
}
|
||||
|
||||
func NewTileObstacle(class string) *Tile {
|
||||
func NewTileObstacle(class string, direction int) *Tile {
|
||||
return &Tile{
|
||||
Id: '+',
|
||||
Sprite: Assets[class],
|
||||
@@ -73,6 +76,7 @@ func NewTileObstacle(class string) *Tile {
|
||||
Solid: false,
|
||||
Renderable: true,
|
||||
Obstacle: true,
|
||||
Direction: direction,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +125,11 @@ func InitTiles() TileRegistry {
|
||||
'#': NewTileBlock("block-grey32"),
|
||||
'S': NewTilePlayer(),
|
||||
'o': NewTileCollectible("collectible-orange"),
|
||||
'+': NewTileObstacle("obstacle-star"),
|
||||
'+': NewTileObstacle("obstacle-star", config.All),
|
||||
'^': NewTileObstacle("obstacle-north", config.North),
|
||||
'v': NewTileObstacle("obstacle-south", config.South),
|
||||
'<': NewTileObstacle("obstacle-east", config.East),
|
||||
'>': NewTileObstacle("obstacle-west", config.West),
|
||||
'*': NewTileParticle([]string{
|
||||
//"particle-ring-1",
|
||||
"particle-ring-2",
|
||||
@@ -143,6 +151,10 @@ func LoadLevels(dir string) []RawLevel {
|
||||
log.Fatalf("failed to read level dir %s: %s", dir, err)
|
||||
}
|
||||
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
return entries[i].Name() < entries[j].Name()
|
||||
})
|
||||
|
||||
for _, levelfile := range entries {
|
||||
if levelfile.Type().IsRegular() && strings.Contains(levelfile.Name(), ".lvl") {
|
||||
path := filepath.Join("assets", dir)
|
||||
|
||||
BIN
assets/sprites/obstacle-east.png
Normal file
BIN
assets/sprites/obstacle-east.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/sprites/obstacle-north.png
Normal file
BIN
assets/sprites/obstacle-north.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/sprites/obstacle-south.png
Normal file
BIN
assets/sprites/obstacle-south.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
BIN
assets/sprites/obstacle-west.png
Normal file
BIN
assets/sprites/obstacle-west.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Reference in New Issue
Block a user