Computer Science Canada Running multiple loops at the same time |
Author: | dwgb93 [ Sun Nov 23, 2008 2:30 pm ] | ||
Post subject: | Running multiple loops at the same time | ||
Hi, guys I need help with a project, and need to have it snowing at the same time smoke is rising from a chimney, while a snowmobile goes across the screen in the background. I can run them all individually, but need help getting them to go all at once. I have tried making them processes and forking them, but it gets extremely flickery. I have also tried putting them all in the same loop, or
I think it is a small error. Can someone please tell me what I am doing wrong? Thank you very much. |
Author: | WaluiJ [ Sun Nov 23, 2008 2:41 pm ] |
Post subject: | Re: Running multiple loops at the same time |
If you want to avoid flickeryness, before the loop, put setscreen ("offscreenonly") and then inside the loop (preferably near the end) put View.Update It'd be better if you told us how you're making the animations go, because there are some problems I've had with View.Update. |
Author: | dwgb93 [ Sun Nov 23, 2008 3:10 pm ] | ||
Post subject: | Re: Running multiple loops at the same time | ||
Here is my code where the whole thing as two seperate loops (instead of a process and a loop, or a loop within a loop) The output s just the background
If I change the smoke loop to a process and fork it inside of the snow loop, the output is correct, but the whole screen flashes like crazy even with offscreenonly and view.Update I just don't get why it is not doin anything. I'm pretty sure it is because of the order of the loops, but I don't know what is wrong with it. |
Author: | Tony [ Sun Nov 23, 2008 3:14 pm ] | ||
Post subject: | Re: Running multiple loops at the same time | ||
dwgb93 @ Sun Nov 23, 2008 2:30 pm wrote: I have tried making them processes and forking them
Don't do that. You should be looking at
Worry about flickering after you get it to work in a loop. At that point it's very easily fixable with offscreenonly, but the same technique will not work with forks. |
Author: | dwgb93 [ Sun Nov 23, 2008 3:24 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Do I want to have View.Update, cls, delay() and the background pic in the code multiple times then? or do I only have them once, and synchronize the movement of each object? If I make it all one loop, the picture shows up, but there is no smoke, and the snow runs across the maxy row. |
Author: | Tony [ Sun Nov 23, 2008 4:08 pm ] | ||
Post subject: | RE:Running multiple loops at the same time | ||
View.Update, cls, and delay should appear just once, inside the loop. Think of it this way
Animation is simply drawing a series of static pictures, such that the difference is small enough for the transition to appear to be smooth. What you have to do is figure out what exactly changes between frame number N and frame number N+1 |
Author: | dwgb93 [ Sun Nov 23, 2008 4:54 pm ] | ||
Post subject: | Re: Running multiple loops at the same time | ||
It works great There is one problem, though. The smoke is behind the house (the chimney) which is good, but the snow is behind it, too (that is bad) If I rearrange the order of the snow, smoke, and cls/Draw the background, then both the smoke and the snow are infront of the house. Here is my code
Can someone tell me how to rearrange the order of the snow, smoke, and background, please Thank you! |
Author: | dwgb93 [ Sun Nov 23, 2008 5:26 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Nevermind I got it! All I did was reinserted the background into the loop directly after the smoke, and before the snow! Thanks |
Author: | WaluiJ [ Sun Nov 23, 2008 5:36 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Oh gee, way to make me waste five minutes figuring it out. ![]() You posted right before I did, so I didn't see it. asdfjsdaf. Program is looking great since I last checked it. What you could do though, to save lines, is draw the objects like the snowman and house seperately in MS paint, then use Pic.ScreenLoad to get them in the picture. Just a thought. |
Author: | dwgb93 [ Sun Nov 23, 2008 5:37 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Thanks a lot, but the snow does not go infront of the house either. In my last post, I found the solution. Thanks anyway |
Author: | dwgb93 [ Sun Nov 23, 2008 6:34 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Great idea. I will post the final program when I have it completed. Thanks a lot, though. |
Author: | dwgb93 [ Sun Nov 23, 2008 8:07 pm ] |
Post subject: | Re: Running multiple loops at the same time |
I have one last problem. My snowmoblie is made up of many drawlines and drawboxes etc To make it move, do I have to change the x and y values of each one? Or is there a way to change the whole thing at once? |
Author: | andrew. [ Sun Nov 23, 2008 8:17 pm ] | ||
Post subject: | RE:Running multiple loops at the same time | ||
Have a variable like snowmobilex. It will keep track of all the snowmobile parts. Each time you go around the loop, add 1 to snowmobilex so that all your parts move. e.g.
|
Author: | dwgb93 [ Sun Nov 23, 2008 8:20 pm ] | ||
Post subject: | Re: Running multiple loops at the same time | ||
Here is the code I have so far. The way the snomobile is travelling is not 100% determined yet, so I gave it simple path to follow until I figure out where it goes. The speed of the program is much slower when I run it, and the snowmoblie is just one blank path, not a moving image.
|
Author: | dwgb93 [ Sun Nov 23, 2008 8:28 pm ] |
Post subject: | Re: Running multiple loops at the same time |
I'm afraid I don't understand. Was the box in the last one supposed to be the same as all of the parts of the snowmobile? Am I supposed to put All of the drawlines, and drawboxes as snowmobilex +/- a number? |
Author: | dwgb93 [ Sun Nov 23, 2008 8:32 pm ] |
Post subject: | Re: Running multiple loops at the same time |
I'm afraid I don't understand. Is the box supposed to be equivalent to the snowmobile? If so, are all of the x coordinates of the parts of the snowmobile supposed to say example: drawline(349+snowmobilex, 45, 234, 45, black)? |
Author: | ecookman [ Mon Nov 24, 2008 8:24 am ] |
Post subject: | RE:Running multiple loops at the same time |
what is this thread supposto be a reply????? makes no sence if you are trying to ask for help please be more descriptive this as far as i know has everything to do with the draw function not as you said Runnning multiple loops at the same time |
Author: | andrew. [ Mon Nov 24, 2008 4:38 pm ] |
Post subject: | RE:Running multiple loops at the same time |
Yes. Make all the parts of the snowmobile in relation to snowmobilex. That way to make it move right, just add to the value of snowmobilex. |
Author: | dwgb93 [ Mon Nov 24, 2008 5:52 pm ] |
Post subject: | Re: Running multiple loops at the same time |
Great, it works! I will just add a few more finishing touches before I am done. Thanks a lot! |
Author: | Tyr_God_Of_War [ Mon Nov 24, 2008 9:27 pm ] |
Post subject: | RE:Running multiple loops at the same time |
Yes. Think of it as moving a bunch of toothpicks: You have to move them all together. |