turing - help w screen output
Author |
Message |
comp_help
|
Posted: 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.
Turing: |
<Add your code here>
|
Please specify what version of Turing you are using
Turing 4.1.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: 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:
code: |
loop
% Update the position of the vehicles here. You can either have them run on some sort of script, or you can just give them a speed and use that to update their locations
% Draw the vehicles here. This should just be a couple of Pic.Draw() commands or perhaps a few calls to a procedure that runs several Draw.FillBox / Draw.Line commands
delay ( 10 ) % Slow it down a little to make sure we see it.
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
comp_help
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Diablo117
![](http://compsci.ca/v3/uploads/user_avatars/6345067144872e0c7b2cf1.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
comp_help
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
Diablo117
![](http://compsci.ca/v3/uploads/user_avatars/6345067144872e0c7b2cf1.jpg)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
|
|