renamed particle* to animation*, added asesprite animation loading

This commit is contained in:
2024-04-02 20:05:23 +02:00
parent 20fa2639c6
commit 001b67f97a
14 changed files with 673 additions and 162 deletions

View File

@@ -57,16 +57,16 @@ func NewGameObserver(
playerID := ecs.ComponentID[components.Player](world)
obstacleID := ecs.ComponentID[components.Obstacle](world)
particleID := ecs.ComponentID[components.Particle](world)
animationID := ecs.ComponentID[components.Animation](world)
playerListener := observer.GetListenerCallback(playerID)
obstacleListener := observer.GetListenerCallback(obstacleID)
particleListener := observer.GetListenerCallback(particleID)
animationListener := observer.GetListenerCallback(animationID)
listen := listener.NewDispatch(
&playerListener,
&obstacleListener,
&particleListener,
&animationListener,
)
world.SetListener(&listen)
@@ -74,7 +74,7 @@ func NewGameObserver(
observer.Entities = make(map[ecs.ID]map[ecs.Entity]int)
observer.Entities[playerID] = make(map[ecs.Entity]int)
observer.Entities[obstacleID] = make(map[ecs.Entity]int)
observer.Entities[particleID] = make(map[ecs.Entity]int)
observer.Entities[animationID] = make(map[ecs.Entity]int)
resmanger := generic.NewResource[GameObserver](world)
resmanger.Add(observer)
@@ -119,20 +119,20 @@ func (observer *GameObserver) GetObstacles() []ecs.Entity {
return observer.GetEntities(obstacleID)
}
func (observer *GameObserver) GetParticles() []ecs.Entity {
particleID := ecs.ComponentID[components.Particle](observer.World)
return observer.GetEntities(particleID)
func (observer *GameObserver) GetAnimations() []ecs.Entity {
animationID := ecs.ComponentID[components.Animation](observer.World)
return observer.GetEntities(animationID)
}
func (observer *GameObserver) RemoveEntities() {
playerID := ecs.ComponentID[components.Player](observer.World)
obstacleID := ecs.ComponentID[components.Obstacle](observer.World)
particleID := ecs.ComponentID[components.Particle](observer.World)
animationID := ecs.ComponentID[components.Animation](observer.World)
observer.Entities = make(map[ecs.ID]map[ecs.Entity]int)
observer.Entities[playerID] = make(map[ecs.Entity]int)
observer.Entities[obstacleID] = make(map[ecs.Entity]int)
observer.Entities[particleID] = make(map[ecs.Entity]int)
observer.Entities[animationID] = make(map[ecs.Entity]int)
}
func (observer *GameObserver) SetupLevelScore(min []int) {