OK I'm trying to ease myself back into this after my years of absence, and I was trying to figure out how to basically move some dots around a screen. Was doing alright, til I remembered I was rubbish, and promptly ran into a bit of a fix.
I have an array storing x and y positions of these dots, as well as their direction and colour. However they all head either left, up or somewhere in between the two - the angles seem limited to the 180-270 range. Also a few dots stay immobile and completely refuse to co-operate.
in BallArray:
(n,1) is x position
(n,2) is y position
(n,3) is object angle
(n,6) is irrelevant to the question but I thought I should include it because it was effort to remove that part, compared to the other bits.
cls
sync on
rem sync rate 60
randomize timer()
dim BallArray(100,7)
for t=1 to 100
BallArray(t,1)=rnd(600)+20
BallArray(t,2)=rnd(440)+20
BallArray(t,3)=rnd(359)
BallArray(t,6)=rnd(2)
next t
do
cls
for t=1 to 100
BallArray(t,1)=newxvalue(BallArray(t,1),BallArray(t,3),1)
BallArray(t,2)=newzvalue(BallArray(t,2),BallArray(t,3),1)
next t
for t=1 to 100
if BallArray(t,6)=0
ink rgb(255,0,0),1
dot BallArray(t,1),BallArray(t,2)-1
dot BallArray(t,1)-1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)
dot BallArray(t,1)+1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)+1
endif
if BallArray(t,6)=1
ink rgb(0,255,0),1
dot BallArray(t,1),BallArray(t,2)-1
dot BallArray(t,1)-1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)
dot BallArray(t,1)+1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)+1
endif
if BallArray(t,6)=2
ink rgb(0,0,255),1
dot BallArray(t,1),BallArray(t,2)-1
dot BallArray(t,1)-1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)
dot BallArray(t,1)+1,BallArray(t,2)
dot BallArray(t,1),BallArray(t,2)+1
endif
next t
sync
loop
Edit: By changing BallArray to a float array instead, the problem of staying immobile or only moving up, down or diagonally up and left has been solved. However there is now a stream going roughly from the bottom left corner to the top right corner.
cls
sync on
rem sync rate 60
randomize timer()
dim BallArray#(100,7)
for t=1 to 100
BallArray#(t,1)=rnd(600)+20
BallArray#(t,2)=rnd(440)+20
BallArray#(t,3)=rnd(359)
BallArray#(t,6)=rnd(2)
next t
do
cls
for t=1 to 100
BallArray#(t,1)=newxvalue(BallArray#(t,1),BallArray#(t,3),1)
BallArray#(t,2)=newyvalue(BallArray#(t,2),BallArray#(t,3),1)
next t
for t=1 to 100
if BallArray#(t,6)=0
ink rgb(255,0,0),1
gosub DrawDot
endif
if BallArray#(t,6)=1
ink rgb(0,255,0),1
gosub DrawDot
endif
if BallArray#(t,6)=2
ink rgb(0,0,255),1
gosub DrawDot
endif
next t
sync
loop
DrawDot:
dot BallArray#(t,1),BallArray#(t,2)-1
dot BallArray#(t,1)-1,BallArray#(t,2)
dot BallArray#(t,1),BallArray#(t,2)
dot BallArray#(t,1)+1,BallArray#(t,2)
dot BallArray#(t,1),BallArray#(t,2)+1
return
I can't figure out why there are only a couple of directions it appears to move in.
"A West Texas girl, just like me"
-Bush