Moveable viewport. Absolute positioning (for UI etc) is possible. Added distance-based bounder for projectiles etc as 'screen' is no longer a suitable bounder. Removed debug msg.

This commit is contained in:
stevenhowes
2022-03-27 17:02:32 +01:00
parent bfa9ab0037
commit 428e2d175c
7 changed files with 88 additions and 24 deletions
+40
View File
@@ -0,0 +1,40 @@
package GoRetro
/*
* --------------------
* BounderDistance
* --------------------
* A bounder which triggers if the distance from spawn to current exceeds range
*/
type bounderDistance struct {
container *Element
callbackFunc func(element *Element)
maxrange float64
}
func NewBounderDistance(container *Element, callback func(element *Element), maxrange float64) *bounderDistance {
return &bounderDistance{
container: container,
callbackFunc: callback,
maxrange: maxrange,
}
}
func (bounder *bounderDistance) onDraw() error {
return nil
}
func (bounder *bounderDistance) onUpdate() error {
b := bounder.container
if vectorDistance(b.Position, b.SpawnPosition) > bounder.maxrange {
bounder.callbackFunc(bounder.container)
}
return nil
}
func (bounder *bounderDistance) onCollision(other *Element) error {
return nil
}