Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Falling From Sky
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
eNc




PostPosted: Thu Jan 20, 2005 4:21 pm   Post subject: Falling From Sky

How would I go about having multiple ovals "falling" from the "sky" at the same time but at different speeds


code:

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
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Thu Jan 20, 2005 4:28 pm   Post subject: (No subject)

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, learn!

EDIT: Posted some code, eh? That looks like the code from your 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




PostPosted: Thu Jan 20, 2005 4:45 pm   Post subject: (No subject)

Cervantes wrote:
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, learn!

EDIT: Posted some code, eh? That looks like the code from your 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.


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




PostPosted: Thu Jan 20, 2005 5:51 pm   Post subject: (No subject)

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




PostPosted: Thu Jan 20, 2005 5:55 pm   Post subject: (No subject)

Quote:
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 Evil dont use em Razz
eNc




PostPosted: Fri Jan 21, 2005 12:17 am   Post subject: (No subject)

basketball4ever wrote:
Quote:
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 Evil dont use em Razz



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




PostPosted: Fri Jan 21, 2005 12:17 am   Post subject: (No subject)

btw thanks
cycro1234




PostPosted: Fri Jan 21, 2005 12:21 am   Post subject: (No subject)

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 Very Happy
Sponsor
Sponsor
Sponsor
sponsor
eNc




PostPosted: Fri Jan 21, 2005 9:52 am   Post subject: (No subject)

Heres my updated code, its still not working well.


code:

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 <= 0
    end loop
end doval
loop
    if dy = 0 then
        dy := 400
    else
        fork doval
        delay (1)
    end if
end loop

Cervantes




PostPosted: Fri Jan 21, 2005 3:48 pm   Post subject: (No subject)

cycro1234 wrote:
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 Very Happy

I already posted a link to that tutorial. And then eNc said he already knew how to use arrays... Rolling Eyes
eNc: You're still using processes. Don't. It is easier and better if you don't.
Neo




PostPosted: Fri Jan 21, 2005 4:39 pm   Post subject: (No subject)

Heres a working one, study it Wink

code:

var x, y, spd : array 1 .. 10 of int
for i : 1 .. 10
    x (i) := Rand.Int (0, maxx)
    y (i) := maxy
    spd (i) := Rand.Int (5, 10)
end for


setscreen ("offscreenonly")
loop
    cls
    for i : 1 .. 10
        drawfilloval (x (i), y (i), 5, 5, blue)
        y (i) -= spd (i)
        if y (i) < 0 then
            x (i) := Rand.Int (0, maxx)
            y (i) := maxy
            spd (i) := Rand.Int (5, 10)
        end if
    end for
    delay (1)
    View.Update
end loop
MysticVegeta




PostPosted: Sat Jan 22, 2005 3:10 pm   Post subject: (No subject)

Or may be some cool snow effect!

code:
var x, y, spd : array 1 .. 10 of int
var colors : array 1 .. 3 of int := init (0, 101, grey)
var z : int

for i : 1 .. 10
    x (i) := Rand.Int (0, maxx)
    y (i) := maxy
    spd (i) := Rand.Int (5, 10)
end for

proc fall
cls
    setscreen ("offscreenonly")
    loop
        cls
        colorback (53)
        drawfillbox (0, 0, maxx, maxy, 53)
        locate (1, 1)
        put "Press any key to exit..."
        for i : 1 .. 10
            z := colors (Rand.Int (1, 3))
            drawfillstar (x (i), y (i), x (i) + 8, y (i) + 6, z)
            y (i) -= spd (i)
            if y (i) < 0 then
                x (i) := Rand.Int (0, maxx)
                y (i) := maxy
                spd (i) := Rand.Int (5, 10)
            end if
            delay ((i * 4) div 10)
        end for
        View.Update
        exit when hasch
    end loop
end fall

fall
eNc




PostPosted: Sat Jan 22, 2005 3:30 pm   Post subject: (No subject)

Beautiful, the snow effect is exactly what i'm looking for. 10 bits to u
Cervantes




PostPosted: Sat Jan 22, 2005 7:21 pm   Post subject: (No subject)

"exactly what i'm looking for" as in "that's what my project was. I'm going to hand your code in and say it was mine?" For your sake, I hope not.
MysticVegeta




PostPosted: Sat Jan 22, 2005 8:22 pm   Post subject: (No subject)

eNc wrote:
Beautiful, the snow effect is exactly what i'm looking for. 10 bits to u


w00t thanks Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: