Computer Science Canada Animating two objects at same time |
Author: | Vesper [ Wed Jan 19, 2005 4:47 pm ] |
Post subject: | Animating two objects at same time |
I'm trying to make a pacman game but turing won't allow me to animate more than one object at the same time (i.e pacman and the ghosts). One object gets all skippy and the other doesn't move at all. I was told that the animation code has to be in one process and under the same delay. I've been trying to get it to work for the last while but don't know what to do. If someone could tell me how to do this it would be greatly appreciated. |
Author: | cycro1234 [ Wed Jan 19, 2005 5:03 pm ] |
Post subject: | |
Well, you could make the animation inside a process, and have a loop inside the process. For example : process pacman loop {Draw pacman} end loop end pacman fork pacman then process ghost loop {Ghost animation} end loop end ghost fork ghost Does that help? |
Author: | Delos [ Wed Jan 19, 2005 5:06 pm ] |
Post subject: | |
1) Hello. 2) In future, post samples of the code that you've been working on. It helps us see where you are, and know that you're not leeching...not as though I'd ever suspect someone who uses Latin in their name to be a leecher. 3) Processes are evil. Instead, what you should do have a single loop in which you will draw your two objects. At the end of the loop you will use a View.Update command. This implies that you will also use setscreen("offscreenonly") at the outset of your code. Press F10 to read up on it. BTW, depening on which version of OOT you're running, View.Update may not have been implemented...but that's mainly the case w/ older versions. |
Author: | Vesper [ Wed Jan 19, 2005 8:43 pm ] | ||||
Post subject: | |||||
I have offscreenonly and View.Update. I've also tried to put pacman in a process but the fact that he has eight filepics depending on what key is pressed, complicates the matter (two per direction). The animation for the ghost is set up like this
and the animation for pacman is not in a process, but in the main loop..
and from the little I know about processes', the ghost should be moving around on its own without messing up pacman's animation. |
Author: | cycro1234 [ Wed Jan 19, 2005 10:22 pm ] |
Post subject: | |
Well, what is it that's your problem? Is it that the pacman moves only? And not the ghosts at the same time. From what I see in ur code, it seems that since ur pacman is in the main loop and not in a process, the main loop will run first and then the ghost. |
Author: | Cervantes [ Wed Jan 19, 2005 10:28 pm ] |
Post subject: | |
Delos wrote: Processes are evil. Instead, what you should do have a single loop in which you will draw your two objects. At the end of the loop you will use a View.Update command.
I'd just like to point out that this is the widely accepted stance on processes in Turing. Processes don't work like you think they do. No program can run perfectly if it uses processes. Find another way! ![]() |
Author: | cycro1234 [ Thu Jan 20, 2005 12:10 am ] |
Post subject: | |
Why is everybody so against processes?? ![]() |
Author: | Vesper [ Thu Jan 20, 2005 4:19 pm ] |
Post subject: | |
Here is exactly whats not working. When I push the arrow key and pacman is moving, both he and the ghost flicker a lot and are slowed down to half of their speed. Also, when he hits a wall and comes to a stop, he disappears completely but the ghost moves perfectly normal. Quote: Processes are evil. Instead, what you should do have a single loop in which you will draw your two objects. At the end of the loop you will use a View.Update command. This implies that you will also use setscreen("offscreenonly") at the outset of your code.
Press F10 to read up on it. The problem with this is that for the pacman to open and close it's mouth, it needs to have a View.Update after each of the filepics (one for open mouth and one for closed mouth). I've tried with one View.Update at the end but it doesn't work. Btw, thanks for the help so far. |
Author: | Cervantes [ Thu Jan 20, 2005 4:36 pm ] | ||||
Post subject: | |||||
You could use either a counter or the Time module and some thinking to make it work, without using processes. Whatever you do, only use one View.Update. They take a long time and using more than one is an unnecessary waste of processing power. Cycro: They don't execute well. Take a look at the output from the folowing program:
See how it produces strings of hi's and strings of ho's, and might even produce a "hiho" or "hohi", or even a blank line. That will screw your program up. What you really want is "hi\nho\nhi\nho" etc.
|
Author: | basketball4ever [ Fri Jan 21, 2005 7:06 pm ] | ||
Post subject: | |||
lol sorta animation : P? |