Computer Science Canada turing - help w screen output |
Author: | comp_help [ Tue Jun 02, 2009 10:39 pm ] | ||
Post subject: | turing - help w screen output | ||
What is it you are trying to achieve? I am trying to move two cars at once on the output screen. What is the problem you are having? The code I have on top executes first and the code on the bottom executes second. Describe what you have tried to solve this problem I have tried making variables and if statements but it doesn't seem to work. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) Will attach code if required.
Please specify what version of Turing you are using Turing 4.1.1 |
Author: | DemonWasp [ Tue Jun 02, 2009 10:48 pm ] | ||
Post subject: | RE:turing - help w screen output | ||
You want to provide the illusion of moving objects by using a bit of a trick that plays on human perception - if we see a series of images, flipped quickly enough, which are similar enough, we see a smooth animation. So what you need to do is show a series of images which are nearly the same. This is called "animation". You keep a location for each of the cars (and their picture...), and do the following:
|
Author: | comp_help [ Tue Jun 02, 2009 10:59 pm ] |
Post subject: | RE:turing - help w screen output |
I tried that but it doesn't seem to work. My car codes are in a for loop and use drawbox commands. Each car has a for loop command. |
Author: | Diablo117 [ Tue Jun 02, 2009 11:02 pm ] |
Post subject: | Re: turing - help w screen output |
Then you might wanna provide either your code, or if you're scared someone will copy, maybe even an exe or fragment of it will do. |
Author: | comp_help [ Tue Jun 02, 2009 11:18 pm ] |
Post subject: | RE:turing - help w screen output |
Here's my code: const midx := maxx div 2 const midy := maxy div 2 loop %left car for x:-30..750 %top body drawbox (x - 30 - 1, midy - 40, x + 30 - 1, midy - 10, white) drawbox (x - 30, midy - 40, x + 30, midy - 10, black) %bottom body drawbox (x - 50 - 1, midy - 40, x + 50 - 1, midy - 60, white) drawbox (x - 50, midy - 40, x + 50, midy - 60, black) %middle line drawline (x - 30, midy - 40, x + 30, midy - 40, white) %left wheel drawfilloval (x - 25, midy - 60, 10, 10, white) drawoval (x - 25 - 1, midy - 60, 10, 10, white) drawoval (x - 25, midy - 60, 10, 10, black) %right wheel drawfilloval (x + 25, midy - 60, 10, 10, white) drawoval (x + 25 - 1, midy - 60, 10, 10, white) drawoval (x + 25, midy - 60, 10, 10, black) exit when x = 115 delay (10) end for %right car for decreasing y:750..-30 %top body drawbox (y + 30 + 1, midy + 50, y - 30 + 1, midy + 70, white) drawbox (y + 30, midy + 50, y - 30, midy + 70, black) %bottom body drawbox (y + 50 + 1, midy + 50, y - 50 + 1, midy + 20, white) drawbox (y + 50, midy + 50, y - 50, midy + 20, black) %middle line drawline (y + 30, midy + 50, y - 30, midy + 50, white) %left wheel drawfilloval (y - 25, midy + 20, 10, 10, white) drawoval (y - 25 + 1, midy + 20, 10, 10, white) drawoval (y - 25, midy + 20, 10, 10, black) %right wheel drawfilloval (y + 25, midy + 20, 10, 10, white) drawoval (y + 25 + 1, midy + 20, 10, 10, white) drawoval (y + 25, midy + 20, 10, 10, black) exit when y = 580 delay (10) end for end loop |
Author: | Diablo117 [ Tue Jun 02, 2009 11:44 pm ] | ||
Post subject: | Re: turing - help w screen output | ||
For loops are run continually until they are exited, and a computer can only do 1 thing at a time, although it can do it very fast.
If you use the old copy and paste, you can see that the squares move "at the same time" while in reality they are moved at different rates, yet the speed of the computer makes it impossible to determine. |