shifted from proprietary ascii rawlevel to LDTK (using ldtkgo@master)

This commit is contained in:
2024-03-10 13:05:31 +01:00
parent a2ed7782b2
commit af19ccb833
15 changed files with 819 additions and 173 deletions

View File

@@ -114,8 +114,8 @@ func (system *CollectibleSystem) AddParticle(position *components.Position) {
pos, particle, timer := ptmapper.Get(entity)
observer.AddEntity(entity, particleID)
particle.Index = assets.Tiles['*'].Particle
particle.Tiles = assets.Tiles['*'].Tiles
particle.Index = assets.Tiles["particle"].Particle
particle.Tiles = assets.Tiles["particle"].Tiles
pos.Update(
position.X-(16), // FIXME: use global tilesize!

View File

@@ -8,16 +8,17 @@ import (
"github.com/hajimehoshi/ebiten/v2"
"github.com/mlange-42/arche/ecs"
"github.com/solarlune/ldtkgo"
)
type HudSystem struct {
World *ecs.World
Cellsize int
Observer *observers.GameObserver
Plan *assets.RawLevel
Plan *ldtkgo.Level
}
func NewHudSystem(world *ecs.World, plan *assets.RawLevel) System {
func NewHudSystem(world *ecs.World, plan *ldtkgo.Level) System {
system := &HudSystem{
Observer: observers.GetGameObserver(world),
World: world,
@@ -45,13 +46,14 @@ func (system *HudSystem) Draw(screen *ebiten.Image) {
*/
score := fmt.Sprintf("Score: %d", system.Observer.GetScore())
level := fmt.Sprintf("Level %d %s", system.Plan.Number, system.Plan.Name)
level := fmt.Sprintf("Level %d %s", system.Plan.PropertyByIdentifier("level").AsInt(),
system.Plan.PropertyByIdentifier("name").AsString())
assets.FontRenderer.Renderer.SetSizePx(20)
assets.FontRenderer.Renderer.SetTarget(screen)
system.Print(score, 515, 22)
system.Print(system.Plan.Description, 10, 470)
system.Print(system.Plan.PropertyByIdentifier("description").AsString(), 10, 470)
system.Print(level, 10, 22)
}

View File

@@ -2,7 +2,6 @@ package systems
import (
"log/slog"
"openquell/assets"
"openquell/components"
. "openquell/components"
. "openquell/config"
@@ -146,33 +145,6 @@ func (system *ObstacleSystem) Draw(screen *ebiten.Image) {
}
}
func (system *ObstacleSystem) AddParticle(position *components.Position) {
observer := observers.GetGameObserver(system.World)
ptmapper := generic.NewMap3[
components.Position,
components.Particle,
components.Timer,
](system.World)
particleID := ecs.ComponentID[components.Particle](system.World)
entity := ptmapper.New()
pos, particle, timer := ptmapper.Get(entity)
observer.AddEntity(entity, particleID)
particle.Index = assets.Tiles['*'].Particle
particle.Tiles = assets.Tiles['*'].Tiles
pos.Update(
position.X-(16), // FIXME: use global tilesize!
position.Y-(16),
64,
)
timer.Start(PARTICLE_LOOPWAIT)
}
// return true if obstacle weapon points into the direction the player is moving
func CheckObstacleSide(playervelocity *Velocity, obsdirection int) bool {
movingdirection := playervelocity.InvertDirection()