mirror of
https://github.com/stevenhowes/GoRetro.git
synced 2026-05-27 00:03:29 +01:00
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:
@@ -1,10 +1,13 @@
|
||||
package GoRetro
|
||||
|
||||
import "fmt"
|
||||
|
||||
/*
|
||||
* --------------------
|
||||
* BounderScreen
|
||||
* --------------------
|
||||
* A bounder which triggers if the element isn't on the screen
|
||||
* TODO: Use dimensions of the entity
|
||||
*/
|
||||
|
||||
type bounderScreen struct {
|
||||
@@ -13,6 +16,10 @@ type bounderScreen struct {
|
||||
}
|
||||
|
||||
func NewBounderScreen(container *Element, callback func(element *Element)) *bounderScreen {
|
||||
if !container.PositionAbsolute {
|
||||
fmt.Println("Added screen bounder to non-absolute positioned element")
|
||||
}
|
||||
|
||||
return &bounderScreen{
|
||||
container: container,
|
||||
callbackFunc: callback,
|
||||
@@ -26,8 +33,8 @@ func (bounder *bounderScreen) onDraw() error {
|
||||
func (bounder *bounderScreen) onUpdate() error {
|
||||
b := bounder.container
|
||||
|
||||
if b.Position.X > float64(Config.ScreenWidth) || b.Position.X < 0 ||
|
||||
b.Position.Y > float64(Config.ScreenHeight) || b.Position.Y < 0 {
|
||||
if b.Position.X > float64(Config.WindowSize.X) || b.Position.X < 0 ||
|
||||
b.Position.Y > float64(Config.WindowSize.Y) || b.Position.Y < 0 {
|
||||
bounder.callbackFunc(bounder.container)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user