min max functions

This commit is contained in:
two-six
2023-10-12 20:33:14 +02:00
parent b260779bc0
commit 47b93e8b03

View File

@@ -78,6 +78,8 @@ func (m *neko) Update() error {
} }
// Prevents neko from being stuck on the side of the screen // Prevents neko from being stuck on the side of the screen
// or randomly travelling to another monitor // or randomly travelling to another monitor
m.x = max(0, min(m.x, monitorWidth))
m.y = max(0, min(m.y, monitorWidth))
if m.x < 0 { if m.x < 0 {
m.x = 0 m.x = 0
} else if m.x >= monitorWidth { } else if m.x >= monitorWidth {