Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 10, 2017 0:54:57 GMT -6
Use the arrow keys to move the object beyond the screen limits to make it re-appear on the opposite side of the screen. ESC to exit.
' ' Wrap-around-demo '
WindowOpen(0,"Wrap Around Demo",0,0,640,480,0) CanvasOpen(0,640,480,0,0,640,480,0)
hidemouse()
blue = rgb(0,0,255) ballx = 300 bally = 220
setColor(blue)
while key(k_escape) = 0
ClearCanvas() if key(k_left) then ballx = ballx - 5 if ballx < -40 then ballx = 640 end if end if if key(k_right) then ballx = ballx + 5 if ballx > 640 then ballx = -40 end if end if if key(k_up) then bally = bally - 5 if bally < -40 then bally = 480 end if end if if key(k_down) then bally = bally + 5 if bally > 480 then bally = -40 end if end if
circleFill(ballx,bally,20)
update() wait(10) wend There is probably a more efficient way of coding this but no one can accuse me of being efficient... lol
Hope this helps.
J
|
|
|
Post by rick3137 on Apr 14, 2017 7:54:04 GMT -6
Works good with Windows10, version RcBasic-Windows927
|
|
|
Post by eyfenna on Apr 17, 2017 8:02:04 GMT -6
Don't think there is a very more efficient way to do it. Even the sfml tutorials employ a similar structure only difference would be that the ball is most likely an object spawned from a class.
Works good.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Apr 17, 2017 15:30:51 GMT -6
There probably is a better way of writing this... mainly because I wrote it and I am not known for my efficiency... lol But thank you all the same.
I only put in "Tips and Tricks" because, when I first started to dabble in coding, I needed something like this example but didn't have a clue as to how to do it myself...
I personally prefer to use sprites, rather than rely on 'primitives', to produce the 'object'. As I am still learning RCBasic, I figured that I would keep it as simple as possible, well as simple as I can imagine... lol
Time for my morning caffeine-fix... Have a great day.
J
|
|