Wiki Diff forum-msg-id-133943-edit, revision #1 to tip
Original date:2019-06-08 21:53:43
Original date:2019-06-08 21:52:21
Edited by: euphoric
Subject: Re: Can't Get Sprite To Stay In Screen Bounds
Should be something like this:
<eucode>
if slGetKey(SL_KEY_LEFT) = 1 then
x -= 2
if x < 0 then
x = 0
end if
slSprite(spr,x,y,32,32)
end if
</eucode>
See if this works:
<eucode>
while not slShouldClose() do
slSetBackColor(255,255,255) --change background to white
if slGetKey(SL_KEY_ESCAPE) = 1 then
slClose()
end if
if slGetKey(SL_KEY_LEFT) = 1 then
x -= 2
if x < 0 then
x = 0
end if
end if
slSprite(spr,x,y,32,32)
slRender()
end while
</eucode>
Edited by: euphoric
Subject: Re: Can't Get Sprite To Stay In Screen Bounds
Should be something like this:
<eucode>
if slGetKey(SL_KEY_LEFT) = 1 then
x -= 2
if x < 0 then
x = 0
end if
slSprite(spr,x,y,32,32)
end if
</eucode>
See if this works:
<eucode>
while not slShouldClose() do
slSetBackColor(255,255,255) --change background to white
if slGetKey(SL_KEY_ESCAPE) = 1 then
slClose()
end if
if slGetKey(SL_KEY_LEFT) = 1 then
x -= 2
if x < 0 then
x = 0
end if
end if
slSprite(spr,x,y,32,32)
slRender()
end while
</eucode>