mirror of
https://github.com/stevenhowes/GoRetro.git
synced 2026-05-26 15:53:31 +01:00
Move all engine stuff to GoRetro. Still many interactions between game and engine code that there should not be.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package GoRetro
|
||||
|
||||
/*
|
||||
* --------------------
|
||||
* BounderScreen
|
||||
* --------------------
|
||||
* A bounder which resets the position to the opposite of
|
||||
* whichever bound was hit
|
||||
*/
|
||||
|
||||
type bounderScreenResetting struct {
|
||||
container *Element
|
||||
}
|
||||
|
||||
func NewBounderScreenResetting(container *Element) *bounderScreenResetting {
|
||||
return &bounderScreenResetting{container: container}
|
||||
}
|
||||
|
||||
func (bounder *bounderScreenResetting) onDraw() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bounder *bounderScreenResetting) onUpdate() error {
|
||||
b := bounder.container
|
||||
|
||||
// If any position exceeds the screen dimensions, wrap it to the
|
||||
// opposite side
|
||||
if b.Position.X > ScreenWidth {
|
||||
b.Position.X = 0
|
||||
}
|
||||
if b.Position.X < 0 {
|
||||
b.Position.X = ScreenWidth
|
||||
}
|
||||
if b.Position.Y > ScreenHeight {
|
||||
b.Position.Y = 0
|
||||
}
|
||||
if b.Position.Y < 0 {
|
||||
b.Position.Y = ScreenWidth
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bounder *bounderScreenResetting) onCollision(other *Element) error {
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user