Computer Science Canada Help! Newbie question! Put two animation in one Execution windows! |
| Author: | Wreathe [ Tue Mar 29, 2011 6:37 pm ] | ||
| Post subject: | Help! Newbie question! Put two animation in one Execution windows! | ||
What is it you are trying to achieve? Display two animation in one execution windows What is the problem you are having? Either one or the other animation stops while the other moves! I want both to move at once! Describe what you have tried to solve this problem I moved the second animation's code everywhere but still didn't work! Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) -----First Code----- View.Set ("offscreenonly") var x,y : array 1 .. 400 of int for snow : 1 .. 400 x (snow) := Rand.Int (0, maxx) y (snow) := Rand.Int (0, maxy) end for loop Draw.FillBox (0, 0, maxx, maxy, black) for snow : 1 .. 400 y (snow) -= Rand.Int (1, 5) if y (snow) < 0 then y (snow) := maxy y (snow) := Rand.Int (0, maxx) end if Draw.FillOval (x (snow), y (snow), 1, 1, white) end for View.Update delay (25) end loop -------Second Code--------- drawfillbox (1, 1, maxx, maxy, black) setscreen ("offscreenonly") for i : 1 .. 225 drawfilloval (i + i, i + i, i, i, white) View.Update delay (50) drawfilloval (i + i, i + i, i, i, black) end for
Please specify what version of Turing you are using 4.1.1 |
|||
| Author: | Tony [ Tue Mar 29, 2011 7:24 pm ] |
| Post subject: | RE:Help! Newbie question! Put two animation in one Execution windows! |
How does a loop (regular loop and for-loop) work? They run the code on the inside, until the loop exists. This should explain why the execution never gets to the second part (loop never exists), and hopefully an idea of what needs to be done. |
|
| Author: | goroyoshi [ Tue Mar 29, 2011 8:04 pm ] |
| Post subject: | Re: Help! Newbie question! Put two animation in one Execution windows! |
try using fork and processes to get them both at the same time |
|
| Author: | Tony [ Tue Mar 29, 2011 8:07 pm ] |
| Post subject: | Re: Help! Newbie question! Put two animation in one Execution windows! |
goroyoshi @ Tue Mar 29, 2011 8:04 pm wrote: try using fork and processes to get them both at the same time
That's not at all what I was going for. Besides, processes are guaranteed to not work correctly with offscreenonly. |
|
| Author: | goroyoshi [ Tue Mar 29, 2011 8:09 pm ] |
| Post subject: | Re: Help! Newbie question! Put two animation in one Execution windows! |
ya i just tried the second animation went all flashy |
|
| Author: | Wreathe [ Wed Mar 30, 2011 7:44 am ] |
| Post subject: | RE:Help! Newbie question! Put two animation in one Execution windows! |
Tony, Even i put my second code inside the "End Loop" of the first code, some other damn error happens! Or you mean, i have to add another loop? If so, please show me where and how! |
|
| Author: | Raknarg [ Wed Mar 30, 2011 8:48 am ] |
| Post subject: | RE:Help! Newbie question! Put two animation in one Execution windows! |
you only need one loop for this program. Instead of using i for your x and y, set those outside your loop and change them on the inside. You have two separate loops; it will only show one thing at a time. If you use one loop, they will work at the same time. I'll refrain from giving code from fear of losing bits from tony |
|
| Author: | Tony [ Wed Mar 30, 2011 1:43 pm ] |
| Post subject: | RE:Help! Newbie question! Put two animation in one Execution windows! |
om nom nom nom bits. @Wreathe -- what kind of an error? How do you think it could be fixed? |
|