Use the 'Edit Post' to get your code above inside a code tag
I see you tried to, it's almost right, take a minute to do that please.
-code-
program
-/code-
replacing - dashes above with [ ] square brackets
In your program...keystate(200)=0 doesn't work, it only works with an 'IF' statement, such as if keystate(200)=0 then...
now...try this code to limit your sprite to the screen edges
set display mode desktop width(),desktop height(),32
sync on
sync rate 60
sync
autocam off
set text opaque
color backdrop 0
load image "floor.png",2
x#=50
y#=0
speed=5
size=50
box 0,0,size,size,rgb(255,0,0),rgb(255,0,0),rgb(255,0,0),rgb(255,0,0),
get image 1,0,0,size,size
minx=0
maxx=desktop width()
miny=0
maxy=desktop height()
do
sprite 2,50,50,2
sprite 1,x#,y#,1
if keystate(200)=1 then dec y#,speed
if keystate(208)=1 then inc y#,speed
if keystate(205)=1 then inc x#,speed
if keystate(203)=1 then dec x#,speed
if x#<minx then x#=minx
if x#>maxx-size then x#=maxx-size
if y#<miny then y#=miny
if y#>maxy-size then y#=maxy-size
`if y# => 0
`keystate(200)=0
`endif
set cursor 0,0
print "x=";x#;" "
print "y=";y#;" "
sync
loop