
-----------------------------------
eNc
Thu Jan 20, 2005 4:21 pm

Falling From Sky
-----------------------------------
How would I go about having multiple ovals "falling" from the "sky" at the same time but at different speeds



var y : int
var x : int := Rand.Int (100, 300)
process doval
y := 400
    loop
        y := y - 1
        drawfilloval (x, y, 5, 5, blue)
        delay (10)
        drawfilloval (x, y, 6, 6, white)
        exit when y < 0
    end loop
end doval
for i : 1 .. 4
    x := Rand.Int (1, 300)
    fork doval
end for


-----------------------------------
Cervantes
Thu Jan 20, 2005 4:28 pm


-----------------------------------
I've told you many times before, in your other thread, to use an array.  Do you know how to use an array?  If so, the answer should be pretty simple.  If not, EDIT: Posted some code, eh?  That looks like the code from your [url=http://www.compsci.ca/v2/viewtopic.php?t=7467]last post.  In fact, it's identical.  It would seem as though you have the exact same question as before.  Instead of spamming the boards with the same question, ask it once.  If you need clarification, ask again, more specifically, in the same thread.  Spamming the boards only causes people to be annoyed with you; you might not get any help as a result. And, of course, you'll lose bits.

-----------------------------------
eNc
Thu Jan 20, 2005 4:45 pm


-----------------------------------
I've told you many times before, in your other thread, to use an array.  Do you know how to use an array?  If so, the answer should be pretty simple.  If not, EDIT: Posted some code, eh?  That looks like the code from your 

yea sorry i meant to post my code with loops. and yes i know how to use an array but i have no clue how that would help me

-----------------------------------
person
Thu Jan 20, 2005 5:51 pm


-----------------------------------
this is how u use arrays!!

var num : array 1 .. 3 of int
var num1 : array 1 .. 3 of int
process doval
    loop
        for j : 1 .. 3
            num1 (j) := 400
        end for
        for j : 1 .. 3
            num1 (j) := num1 (j) - Rand.Int (1, 50)
        end for
        for i : 1 .. 3
            drawfilloval (num (i), num1 (i), 5, 5, blue)
            delay (100)
            drawfilloval (num (i), num1 (i), 6, 6, white)
        end for

        exit when num1 (1) < 0 or num1 (2) < 0 or num1 (3) < 0
    end loop
end doval
for i : 1 .. 4
    loop
        y := 400
        for a : 1 .. 3
            num (a) := Rand.Int (1, 300)
        end for
        fork doval
        delay (1000)
    end loop
end for

-----------------------------------
basketball4ever
Thu Jan 20, 2005 5:55 pm


-----------------------------------
this is how u use arrays!! 

var num : array 1 .. 3 of int 
var num1 : array 1 .. 3 of int 
process doval 
loop 
for j : 1 .. 3 
num1 (j) := 400 
end for 
for j : 1 .. 3 
num1 (j) := num1 (j) - Rand.Int (1, 50) 
end for 
for i : 1 .. 3 
drawfilloval (num (i), num1 (i), 5, 5, blue) 
delay (100) 
drawfilloval (num (i), num1 (i), 6, 6, white) 
end for 

exit when num1 (1) < 0 or num1 (2) < 0 or num1 (3) < 0 
end loop 
end doval 
for i : 1 .. 4 
loop 
y := 400 
for a : 1 .. 3 
num (a) := Rand.Int (1, 300) 
end for 
fork doval 
delay (1000) 
end loop 
end for

that aint gonna teach him buddy x_X ... lol try explaining it to him... cos like this is just a bunch of code to him : P and as mentioned before... procecsses are evil  :twisted:  dont use em  :P

-----------------------------------
eNc
Fri Jan 21, 2005 12:17 am


-----------------------------------
this is how u use arrays!! 

var num : array 1 .. 3 of int 
var num1 : array 1 .. 3 of int 
process doval 
loop 
for j : 1 .. 3 
num1 (j) := 400 
end for 
for j : 1 .. 3 
num1 (j) := num1 (j) - Rand.Int (1, 50) 
end for 
for i : 1 .. 3 
drawfilloval (num (i), num1 (i), 5, 5, blue) 
delay (100) 
drawfilloval (num (i), num1 (i), 6, 6, white) 
end for 

exit when num1 (1) < 0 or num1 (2) < 0 or num1 (3) < 0 
end loop 
end doval 
for i : 1 .. 4 
loop 
y := 400 
for a : 1 .. 3 
num (a) := Rand.Int (1, 300) 
end for 
fork doval 
delay (1000) 
end loop 
end for

that aint gonna teach him buddy x_X ... lol try explaining it to him... cos like this is just a bunch of code to him : P and as mentioned before... procecsses are evil  :twisted:  dont use em  :P


Umm well heres what i think it does, now i could be wrong but just confirm this for me please, in the first process it sets all the values in num1 array to 400 then it sets all the values in the array num1 to num1 - a random number from 1, 50, then it draws 3 ovals each with x, and y values which are relative to the num1 array value stored in the location that i points to, it then draws a white circle over it after the time delay, then it chesk to see if the num1 value stored in the array is less than 0 and so on, then quits loop if true, the process is ended, here's where im not sure, it seems to create a for loop which will execute 4 times but only executes 1ce because the inner loop never really stops, then in the inner for loop it sets the array num value to a random number, it fills the array this way, ends for loop, it executes doval, and then delays and then ends loop and loops around again. Please correct me if I'm wrong anywhere, I'm always willing to learn more.

-----------------------------------
eNc
Fri Jan 21, 2005 12:17 am


-----------------------------------
btw thanks

-----------------------------------
cycro1234
Fri Jan 21, 2005 12:21 am


-----------------------------------
So u wanna learn arrays EH? Willing to learn more, EH? Then go to http://www.compsci.ca/v2/viewtopic.php?t=366 for an excellent tutorial on arrays  :D

-----------------------------------
eNc
Fri Jan 21, 2005 9:52 am


-----------------------------------
Heres my updated code, its still not working well.



var dx : array 1 .. 3 of int
var dy : int := 400
var count := 0
process doval
    loop
        count := count + 1
        if count = 1 then
            for i : 1 .. 3
                dx (i) := 400
            end for
            for i : 1 .. 3
                dx (i) := dx (i) - Rand.Int (1, 200)
            end for
        end if
        dy := dy - 10
        loop
            drawfilloval (dx (1), dy, 5, 5, blue)
            drawfilloval (dx (2), dy, 5, 5, blue)
            drawfilloval (dx (3), dy, 5, 5, blue)
            delay (10)
            drawfilloval (dx (1), dy, 5, 5, white)
            drawfilloval (dx (2), dy, 5, 5, white)
            drawfilloval (dx (3), dy, 5, 5, white)
        end loop
        exit when dx (1) < 0 or dx (2) < 0 or dx (3) < 0 or dy 