I've written this code to handle them and so far it works satisfactorily:
Code: [Local Link Removed for Guests]
firstTime = 1
xM = 639 : yM = 479
xC = 319 : yC = 239
x = 0 : y = 0
x0 = 0 : y0 = 0
up = 16 : dwn = 17
lft = 21 : rht = 22
mid = 1
pin.mode up, input, pullup
pin.mode dwn, input, pullup
pin.mode lft, input, pullup
pin.mode rht, input, pullup
pin.mode mid, input, pullup
interrupt mid, mid
while 1
if pin(dwn) = 0 then y = y + 1
if pin(up) = 0 then y = y - 1
if pin(rht) = 0 then x = x + 1
if pin(lft) = 0 then x = x - 1
if x > xM then x = xM
if y > yM then y = yM
if x < 0 then x = 0
if y < 0 then y = 0
if (x0 <> x) OR (y0 <> y) then
x0 = x : y0 = y
gosub moving
endif
wend
END
' -----------------
moving:
wlog x, y
return
' -----------------
mid:
if firstTime then
firstTime = 0
return
endif
if pin(mid) = 0 then return
x = xC : y = yC
return
I tried to find, both in the old forum and in this current one, examples on which to base myself, but I did not find anything.
Greetings to all.