mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-07-26 11:24:38 -04:00
* removed d2common/d2scene, was not the right way to go. * added components for animation, scale, main viewport, viewport filter * added interface for scenes, which are extensions of akara.System * BootStrap is now AppBootstrap, common to game clients and headless server * added generic BasicScene struct for common scene functionality * added game object factory as a system, with single sprite factory * added update counter system, shows how many times the world updates per second * integration test is now the game client test
55 lines
875 B
Go
55 lines
875 B
Go
package d2systems
|
|
|
|
import (
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
|
|
"github.com/gravestench/akara"
|
|
)
|
|
|
|
const (
|
|
logPrefixUpdateCounter = "Update Counter"
|
|
)
|
|
|
|
func NewUpdateCounterSystem() *UpdateCounter {
|
|
uc := &UpdateCounter{
|
|
BaseSystem: &akara.BaseSystem{},
|
|
Logger: d2util.NewLogger(),
|
|
}
|
|
|
|
uc.SetPrefix(logPrefixUpdateCounter)
|
|
|
|
return uc
|
|
}
|
|
|
|
var _ akara.System = &UpdateCounter{}
|
|
|
|
type UpdateCounter struct {
|
|
*akara.BaseSystem
|
|
*d2util.Logger
|
|
secondsElapsed float64
|
|
count int
|
|
}
|
|
|
|
func (u *UpdateCounter) Init(world *akara.World) {
|
|
u.World = world
|
|
|
|
if u.World == nil {
|
|
u.SetActive(false)
|
|
}
|
|
|
|
u.Info("initializing")
|
|
}
|
|
|
|
func (u *UpdateCounter) Update() {
|
|
u.count++
|
|
u.secondsElapsed += u.World.TimeDelta.Seconds()
|
|
|
|
if u.secondsElapsed < 1 {
|
|
return
|
|
}
|
|
|
|
u.Infof("%d updates per second", u.count)
|
|
u.secondsElapsed = 0
|
|
u.count = 0
|
|
}
|
|
|