fixed slow grid drawing, which also fixed transient tile quirk
This commit is contained in:
parent
1c0f3d19d0
commit
6f85a90b58
8
TODO.md
8
TODO.md
@ -14,12 +14,6 @@
|
|||||||
|
|
||||||
- Add shaders for animation (player destruction etc)
|
- Add shaders for animation (player destruction etc)
|
||||||
|
|
||||||
- Add Score system, see game_observer.go bottom.
|
|
||||||
- add MinMoves to each level (one line) [min moves to win]
|
|
||||||
- count moves in player_scene.Update (put to observer as well?)
|
|
||||||
- reset counters when new level starts
|
|
||||||
- display level score in level select
|
|
||||||
|
|
||||||
- for finding caller:
|
- for finding caller:
|
||||||
pc := make([]uintptr, 10)
|
pc := make([]uintptr, 10)
|
||||||
n := runtime.Callers(0, pc)
|
n := runtime.Callers(0, pc)
|
||||||
@ -32,7 +26,7 @@
|
|||||||
slog.Debug("get observer", "minmoves", observer.LevelScore,
|
slog.Debug("get observer", "minmoves", observer.LevelScore,
|
||||||
"file", source.File, "line", source.Line)
|
"file", source.File, "line", source.Line)
|
||||||
|
|
||||||
## Collider Rework
|
## Collider Rework [abandoned: see branch collider-system, fails]
|
||||||
|
|
||||||
- do not use the map anymore for collision detection
|
- do not use the map anymore for collision detection
|
||||||
- central collision_system
|
- central collision_system
|
||||||
|
|||||||
@ -11,6 +11,6 @@ const (
|
|||||||
All
|
All
|
||||||
)
|
)
|
||||||
|
|
||||||
const PLAYERSPEED int = 4
|
const PLAYERSPEED int = 5
|
||||||
const PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond
|
const PARTICLE_LOOPWAIT time.Duration = 250 * time.Millisecond
|
||||||
const LEVEL_END_WAIT time.Duration = 500 * time.Millisecond
|
const LEVEL_END_WAIT time.Duration = 500 * time.Millisecond
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
|
||||||
"image/draw"
|
|
||||||
"log/slog"
|
|
||||||
. "openquell/components"
|
. "openquell/components"
|
||||||
|
|
||||||
"github.com/hajimehoshi/ebiten/v2"
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
@ -40,32 +37,33 @@ func NewGridSystem(world *ecs.World, width, height,
|
|||||||
return system
|
return system
|
||||||
}
|
}
|
||||||
|
|
||||||
func (system *GridSystem) Update() error { return nil }
|
func (system *GridSystem) Update() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (system *GridSystem) Draw(screen *ebiten.Image) {
|
func (system *GridSystem) Draw(screen *ebiten.Image) {
|
||||||
op := &ebiten.DrawImageOptions{}
|
op := &ebiten.DrawImageOptions{}
|
||||||
query := system.Selector.Query(system.World)
|
query := system.Selector.Query(system.World)
|
||||||
|
|
||||||
if !system.UseCache || query.Count() != system.Count {
|
if !system.UseCache || query.Count() != system.Count {
|
||||||
slog.Debug("entity number changes", "old", system.Count, "current", query.Count())
|
|
||||||
// map not cached or cacheable, write it to the cache
|
// map not cached or cacheable, write it to the cache
|
||||||
draw.Draw(system.Cache, system.Background.Bounds(), system.Background, image.ZP, draw.Src)
|
system.Cache.DrawImage(system.Background, op)
|
||||||
|
|
||||||
system.Count = query.Count()
|
system.Count = query.Count()
|
||||||
|
counter := 0
|
||||||
for query.Next() {
|
for query.Next() {
|
||||||
sprite, pos, _ := query.Get()
|
sprite, pos, _ := query.Get()
|
||||||
|
counter++
|
||||||
//slog.Debug("drawing sprite", "sprite", sprite, "point", pos.Point())
|
op.GeoM.Reset()
|
||||||
draw.Draw(
|
op.GeoM.Translate(float64(pos.X), float64(pos.Y))
|
||||||
system.Cache,
|
system.Cache.DrawImage(sprite.Image, op)
|
||||||
image.Rect(pos.X, pos.Y, pos.X+pos.Cellsize, pos.Y+pos.Cellsize),
|
|
||||||
sprite.Image, image.ZP, draw.Over)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
op.GeoM.Reset()
|
op.GeoM.Reset()
|
||||||
screen.DrawImage(system.Cache, op)
|
screen.DrawImage(system.Cache, op)
|
||||||
|
|
||||||
system.UseCache = true
|
system.UseCache = true
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// use the cached map
|
// use the cached map
|
||||||
op.GeoM.Reset()
|
op.GeoM.Reset()
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package systems
|
package systems
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log/slog"
|
||||||
"openquell/assets"
|
"openquell/assets"
|
||||||
"openquell/components"
|
"openquell/components"
|
||||||
. "openquell/components"
|
. "openquell/components"
|
||||||
@ -78,17 +79,19 @@ func (system *TransientSystem) Update() error {
|
|||||||
Position: *transientposition,
|
Position: *transientposition,
|
||||||
NewSprite: transient.GetNext(),
|
NewSprite: transient.GetNext(),
|
||||||
})
|
})
|
||||||
//slog.Debug("done transient", "transient", transientposition)
|
slog.Debug("transient added to make solid")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, convertible := range EntitiestoMakeSolid {
|
for _, convertible := range EntitiestoMakeSolid {
|
||||||
|
slog.Debug("transient remove")
|
||||||
// remove transient entity
|
// remove transient entity
|
||||||
system.World.RemoveEntity(convertible.Entity)
|
system.World.RemoveEntity(convertible.Entity)
|
||||||
|
|
||||||
// replace with solid entity
|
// replace with solid entity
|
||||||
|
slog.Debug("transient add solid")
|
||||||
entity := system.SolidMapper.New()
|
entity := system.SolidMapper.New()
|
||||||
pos, render, _, _ := system.SolidMapper.Get(entity)
|
pos, render, _, _ := system.SolidMapper.Get(entity)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user