- use toggle tile for all toggling entities (transient, switch, door)
- get rod of hard coded sprites (exception: particle class, to be
  fixed later)
- changed switch sprite (rect instead of elipse)
This commit is contained in:
2024-03-31 20:16:15 +02:00
parent f6f2172f11
commit faf0fd99c2
24 changed files with 334 additions and 339 deletions

View File

@@ -1,6 +1,7 @@
package systems
import (
"log/slog"
. "openquell/components"
"github.com/hajimehoshi/ebiten/v2"
@@ -53,10 +54,13 @@ func (system *GridSystem) Draw(screen *ebiten.Image) {
counter := 0
for query.Next() {
sprite, pos, _ := query.Get()
counter++
op.GeoM.Reset()
op.GeoM.Translate(float64(pos.X), float64(pos.Y))
slog.Debug("rendering tile", "sprite", sprite)
system.Cache.DrawImage(sprite.Image, op)
}
op.GeoM.Reset()

View File

@@ -72,6 +72,7 @@ func (system *PairSystem) Update() error {
if ok {
// player moved on top of the switch
switcher.Toggle()
// open door
door := system.World.Relations().Get(query.Entity(), relID)
EntitiesToSwitch = append(EntitiesToSwitch,

View File

@@ -26,7 +26,7 @@ type TransientSystem struct {
type TransientToWall struct {
Entity ecs.Entity
NewSprite string
NewSprite *ebiten.Image
Position components.Position
}
@@ -77,7 +77,7 @@ func (system *TransientSystem) Update() error {
EntitiestoMakeSolid = append(EntitiestoMakeSolid, TransientToWall{
Entity: query.Entity(),
Position: *transientposition,
NewSprite: transient.GetNext(),
NewSprite: transient.Wall,
})
slog.Debug("transient added to make solid")
}
@@ -91,18 +91,20 @@ func (system *TransientSystem) Update() error {
system.World.RemoveEntity(convertible.Entity)
// replace with solid entity
slog.Debug("transient add solid")
slog.Debug("transient add solid", "wall", convertible.NewSprite.Bounds())
entity := system.SolidMapper.New()
pos, render, _, _ := system.SolidMapper.Get(entity)
// set it up apropriately
pos.Set(&convertible.Position)
render.Image = assets.Assets[convertible.NewSprite]
render.Image = convertible.NewSprite
render.Pos = pos
slog.Debug("new render", "render", render)
// also setup the grid tile with a new solid, so that
// collision detection works
system.GridContainer.Grid.SetSolidTile(
assets.NewTileBlock(convertible.NewSprite),
assets.NewTileBlock(),
convertible.Position.Point(),
)
}