
-----------------------------------
TokenHerbz
Thu Jul 21, 2005 10:02 pm

Problem Bouncing
-----------------------------------
Hi, i read all the totorials, believe you me, and maybe i dont know what its sopposed to be like, and passed it, so sorry if i made you mad.

setscreen ("Graphics,500,500")

var ballc: array 1 .. 5 of int
var ballx: array 1 .. 5 of int
var bally: array 1 .. 5 of int
var ballx1: array 1 .. 5 of int

for i: 1 .. 5
    randint(ballc(i),1,99)
end for

for i: 1 .. 5
    randint (ballx(i),100,400)
end for

for i: 1 .. 5
    randint (bally(i),100,400)
end for

for i: 1 .. 5
    randint (ballx1(i),1,10)
end for

for i: 1 .. 5
    drawfilloval (ballx(i),bally(i),ballx1(i),ballx1(i),ballc(i))
end for

------------------------
Thats my code for now, i know how to make boudries OFF the sides, i need help making the balls bounce off each other...

Also, i dont know how to make them move in random directions from start, gaining speed each time 1 hits either another ball, or the sides.

Im thinking i need a loop AFTER my for statments...  but i tryed like 
for i: 1 .. 5
    ballx(i) := ball + 1
end for

it dosn't work, i tryed more, nothings random, and i just need some help trying to understand more of this.

with the boundries, 

for i: 1 .. 5
     if ballx(i) >= maxx - 10 then
           ballx(i) := maxx - 10
      elsif ballx(i) = maxx - balls(i) then
            ballvx(i) *= -1
        elsif ballx(i) = maxy - balls(i) then
            ballvy(i) *= -1
        elsif bally(i)  So many arrays  :shock: Check out record in the turing walkthrough. Example of what you could do ->
var something : array 1 .. 10 of
    record
        x : int
        y : int
        vy : int
        vx : int
        c : int
    end record


And to call a record, its really easy..



for s : 1 .. 10
    something (s).x := s * 2
    something (s).y := s div 2
    something (s).vy := s ** 2
    something (s).vx := s - 2
    something (s).c := s + 2
end for


-----------------------------------
TokenHerbz
Sat Jul 23, 2005 9:31 pm


-----------------------------------
ok, but hows that help my problem?

the balls, they don't bounce off of each other.

-----------------------------------
Cervantes
Mon Jul 25, 2005 8:12 pm


-----------------------------------
Have you looked at the link I gave you?  The one to thoughtful's pool.  You'll have to adapt it to your program yourself.  


ok, but hows that help my problem? 

It makes your code more organized, readable, understandable, and therefore better.

-----------------------------------
MysticVegeta
Tue Jul 26, 2005 6:05 pm


-----------------------------------
couldnt have said that better myself, Geoff
