From bc3341bc0700f9cd812616806dbc65924d73217f Mon Sep 17 00:00:00 2001 From: djib Date: Thu, 11 Nov 2021 21:52:58 +0100 Subject: [PATCH] Limiting guy's movement within the screen --- pyras.p8 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyras.p8 b/pyras.p8 index 5af47a6..3d49ed5 100644 --- a/pyras.p8 +++ b/pyras.p8 @@ -18,10 +18,10 @@ guyspeedx=2 guyspeedy=2 function moveguy() - if (btn(0)) guyposx-=guyspeedx - if (btn(1)) guyposx+=guyspeedx - if (btn(2)) guyposy-=guyspeedy - if (btn(3)) guyposy+=guyspeedy + if (btn(0)) guyposx=max(0,guyposx-guyspeedx) + if (btn(1)) guyposx=min(127,guyposx+guyspeedx) + if (btn(2)) guyposy=max(0,guyposy-guyspeedy) + if (btn(3)) guyposy=min(127,guyposy+guyspeedy) end function drawguy()