Process Help
Author |
Message |
eNc
|
Posted: Wed Jan 19, 2005 7:09 pm Post subject: Process Help |
|
|
I'm trying to get it to drop at least 2 ovals at the same time, the x value is random at the beging of each drop. Its not really working too well so I was wondering if anyone had some suggestions.
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
|
|
|
Cervantes
|
Posted: Wed Jan 19, 2005 7:58 pm Post subject: (No subject) |
|
|
Don't use a process. Have an array to store the y value for various ovals, as well as one for the x value. Each time through your loop, subtract one (or whateer value you want) from the y value of each array. |
|
|
|
|
|
eNc
|
Posted: Wed Jan 19, 2005 8:16 pm Post subject: (No subject) |
|
|
Cervantes wrote: Don't use a process. Have an array to store the y value for various ovals, as well as one for the x value. Each time through your loop, subtract one (or whateer value you want) from the y value of each array.
how can i get it to draw 2 + objects simultaneously if i don't use a process? |
|
|
|
|
|
Cervantes
|
Posted: Wed Jan 19, 2005 8:26 pm Post subject: (No subject) |
|
|
To draw two objects simultaneously:
code: |
drawfillbox (100, 100, 150, 150, 7)
drawfillbox (150, 100, 200, 150, 12)
|
That's almost simultaneously. If you want it really simultaneous, use View.Update. |
|
|
|
|
|
eNc
|
Posted: Wed Jan 19, 2005 9:38 pm Post subject: (No subject) |
|
|
Cervantes wrote: To draw two objects simultaneously:
code: |
drawfillbox (100, 100, 150, 150, 7)
drawfillbox (150, 100, 200, 150, 12)
|
That's almost simultaneously. If you want it really simultaneous, use View.Update.
How would i go abouyt animating somthing simultaneously? and do i just put View.Update after the drawfillboxes? |
|
|
|
|
|
cycro1234
|
Posted: Wed Jan 19, 2005 9:48 pm Post subject: (No subject) |
|
|
Well, if the boxes both increase or decrease by the same values, you could put them under one loop.
var x: int := 100
loop
x :=x +1
drawfillbox (100+x,100,200+x,200,7)
delay (20)
drawfillbox (400-x,200,500-x,300,7)
exit when x < 0 or x > 600
end loop |
|
|
|
|
|
eNc
|
Posted: Wed Jan 19, 2005 9:57 pm Post subject: (No subject) |
|
|
cycro1234 wrote: Well, if the boxes both increase or decrease by the same values, you could put them under one loop.
var x: int := 100
loop
x :=x +1
drawfillbox (100+x,100,200+x,200,7)
delay (20)
drawfillbox (400-x,200,500-x,300,7)
exit when x < 0 or x > 600
end loop
no actually, the ovals change their y location at different rates. |
|
|
|
|
|
cycro1234
|
Posted: Wed Jan 19, 2005 10:14 pm Post subject: (No subject) |
|
|
Then u can make 2 separate processes for each oval, and fork them. To use View.Update you need as your very first line setscreen ("offscreenonly")
Then whenever u have animations, stick in a View.Update |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cervantes
|
Posted: Wed Jan 19, 2005 10:19 pm Post subject: (No subject) |
|
|
No, you don't do that. You make an array to store the movement of each oval. Then, in a for loop contained within your main loop, you add the movement of each oval to the location. Don't use processes. |
|
|
|
|
|
eNc
|
Posted: Wed Jan 19, 2005 10:35 pm Post subject: (No subject) |
|
|
Cervantes wrote: Then, in a for loop contained within your main loop, you add the movement of each oval to the location. Don't use processes.
i'm not sure i totallly understand
this is what i'm aiming for my program to do, Ovals fall form the top, your "paddle" dodges them with user movement, after time more ovals are randomly generated moving at different rates with different x locations, of which the user has to dodge |
|
|
|
|
|
|
|