obstacle collission added, but not working yet

This commit is contained in:
2024-02-20 18:47:32 +01:00
parent fd570216f0
commit 646b227b8e
15 changed files with 112 additions and 21 deletions

View File

@@ -5,13 +5,13 @@ Background: background-lila
########
# o # #
# S # #
#v o #
# S<# #
# #### #
# #### #
# #
# #
#> ^#
########

View File

@@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB