diff options
| author | ewy <ewy0@protonmail.com> | 2026-08-13 15:25:59 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-08-13 15:25:59 +0200 |
| commit | bc3f852ea670e206fa3facc736a230f6b9d23920 (patch) | |
| tree | 198bdb2107108fe0cbe83836c8d14688128ba80c /objs | |
| parent | 60f58e548ef745ec072482954ac37c35d88280d4 (diff) | |
clamp mous
Diffstat (limited to 'objs')
| -rw-r--r-- | objs/cursor.go | 12 |
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 { |
