summaryrefslogtreecommitdiff
path: root/objs
diff options
context:
space:
mode:
Diffstat (limited to 'objs')
-rw-r--r--objs/cursor.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/objs/cursor.go b/objs/cursor.go
index 817279b..2a676fe 100644
--- a/objs/cursor.go
+++ b/objs/cursor.go
@@ -8,6 +8,12 @@ import (
type Cursor struct {
*ecs.GameObject
+ MaxX, MaxY float32
+}
+
+func (c *Cursor) ProcessWindowChange(ev events.WindowChange) {
+ c.MaxX = float32(ev.Width)
+ c.MaxY = float32(ev.Height)
}
func (c *Cursor) Render(renderer *sdl.Renderer) {
@@ -31,6 +37,12 @@ func (c *Cursor) ProcessMouseMotion(ev events.MouseMotion) {
if c.Position.Y < 0 {
c.Position.Y = 0
}
+ if c.Position.X > c.MaxX {
+ c.Position.X = c.MaxX
+ }
+ if c.Position.Y > c.MaxY {
+ c.Position.Y = c.MaxY
+ }
}
func (c *Cursor) GO() *ecs.GameObject {