What's the best way to keep the player in bounds? I am noticing that without boundary walls on the edges of the screen, the game crashes if the player attempts to move off the edge of the screen.
Perhaps listen for player position (px,py) when player is along an edge, prevent the player from moving further with gotos?
Here's what I have, but feels hacky. Open to a better solution.
(player script)
on update do
x = event.px
y = event.py
currentRoom = event.room
// preload corrected coordinates
correctTop = y
correctTop++
correctBot = y
correctBot--
correctLeft = x
correctLeft++
correctRight = x
correctRight--
// top and Bottom boundaries
if y == 0 then
goto x,correctTop in currentRoom
elseif y == 13 then
goto x,correctBot in currentRoom
end
// left and right boundaries
if x == 0 then
goto correctLeft,y in currentRoom
elseif x == 24 then
goto correctRight,y in currentRoom
end
call "moveBot" // draw player sprite
end