4 ms·
Yay, doughnut space! I played with this kinda stuff as a kid back in the QBasic days. Like Asteroids style. Basically: If X>10 then X=0 If Y>10 then Y=0 An
by kleer001 3y ago
Yay, doughnut space! I played with this kinda stuff as a kid back in the QBasic days.
Like Asteroids style.
Basically:
If X>10 then X=0
If Y>10 then Y=0
And then again
If X<0 then X=10
If Y<0 then Y=10
- gpderetta 3y agoThe issue is that in 3d the mapping is less straightforward if you want avoid stange effects like being mirrored .
- munificent 3y agoYou actually want: while x > 10 do x -= 10 while x < 0 do x += 10 while y > 10 do y -= 10 while y < 0 do y += 10 What you have will discard some position information every time it wraps. Also, it won't correctly handle changes in position per frame that are larger than 10.
- kleer001 3y agoWell, yes, but I also need to take account of velocity and rotation too. I don't see that particular flow in the manual, and of course everything should be FULLCAPS. https://en.wikibooks.org/wiki/QBasic/Full_Book_View#DO_.._LOOP https://en.wikibooks.org/wiki/QBasic/Full_Book_View#DO_.._LO...
- notfish 3y agoOr just x = x mod 10 y = y mod 10
- munificent 3y agoThat depends on how the programming language implements modulo. Some don't wrap around the way you would need here when the dividend is negative. See: https://en.wikipedia.org/wiki/Modulo#Variants_of_the_definition https://en.wikipedia.org/wiki/Modulo#Variants_of_the_definit...
- ithkuil 3y agoWould this work in both flavours of the modulo operator? x = ((x mod 10) + 10) mod 10