Пример #1
0
func (r *RotationSystem) Update(dt float32) {
	// speed in radians per second
	var speed float32 = math.Pi
	// speed in degrees per second
	var speedDegrees float32 = speed * 180 / math.Pi

	for _, e := range r.entities {
		e.SpaceComponent.Rotation += speedDegrees * dt
		e.SpaceComponent.Rotation = math.Mod(e.SpaceComponent.Rotation, 360)
	}
}
Пример #2
0
func (c *Clock) Tick() {
	now := time.Now()
	c.frames += 1
	if !c.frame.IsZero() {
		c.delta = float32(now.Sub(c.frame).Seconds())
	}

	c.elapsed += c.delta
	c.frame = now

	if c.elapsed >= 1 {
		c.fps = float32(c.frames)
		c.elapsed = math.Mod(c.elapsed, 1)
		c.frames = 0
	}
}
Пример #3
0
func (cam *cameraSystem) rotateTo(rotation float32) {
	cam.angle = math.Mod(rotation, 360)
}