Turing elevator floors help
Author |
Message |
supadupamegaman
|
Posted: Tue Jan 08, 2013 1:38 pm Post subject: Turing elevator floors help |
|
|
What is it you are trying to achieve?
I am trying to get my elevator to stop at a certain level. For example, if I click the floor 2 button, the elevator will go to floor 2.
What is the problem you are having?
The elevator goes past the desired floor and goes up out of the screen.
Describe what you have tried to solve this problem.
I have tried making a procedure for all 3 floors, but they are not stopping. I believe you can make an if statement for the buttons and how far the elevator moves, but I am unsure how to do that.
Please specify what version of Turing you are using
4.1.1a
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
cs isp.t |
Filesize: |
5.96 KB |
Downloaded: |
64 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Tue Jan 08, 2013 3:31 pm Post subject: RE:Turing elevator floors help |
|
|
Turing: |
procedure move_elevator
loop
count := count + 1
drawline (round (elevator_pointx1 ), round (elevator_pointy1 + count ), round (elevator_pointx2 ), round (elevator_pointy2 + count ), black)
drawline (round (elevator_pointx2 ), round (elevator_pointy2 + count ), round (elevator_pointx3 ), round (elevator_pointy3 + count ), black)
drawline (round (elevator_pointx3 ), round (elevator_pointy3 + count ), round (elevator_pointx4 ), round (elevator_pointy4 + count ), black)
drawline (round (elevator_pointx4 ), round (elevator_pointy4 + count ), round (elevator_pointx1 ), round (elevator_pointy1 + count ), black)
drawline (round (elevator_pointx1 + 50), round (elevator_pointy1 + count ), round (elevator_pointx2 + 50), round (elevator_pointy2 + count ), black)
delay (DELAY )
drawline (round (elevator_pointx1 ), round (elevator_pointy1 + count ), round (elevator_pointx2 ), round (elevator_pointy2 + count ), white)
drawline (round (elevator_pointx2 ), round (elevator_pointy2 + count ), round (elevator_pointx3 ), round (elevator_pointy3 + count ), white)
drawline (round (elevator_pointx3 ), round (elevator_pointy3 + count ), round (elevator_pointx4 ), round (elevator_pointy4 + count ), white)
drawline (round (elevator_pointx4 ), round (elevator_pointy4 + count ), round (elevator_pointx1 ), round (elevator_pointy1 + count ), white)
drawline (round (elevator_pointx1 ), round (elevator_pointy1 ), round (elevator_pointx4 ), round (elevator_pointy4 ), white)
drawline (round (elevator_pointx2 ), round (elevator_pointy2 ), round (elevator_pointx3 ), round (elevator_pointy3 ), white)
end loop
end move_elevator |
There is nothing here to stop the elevator. You need to exit the loop when the elevator is at the correct height. To do this, you need a variable to record which floor to go to, and which floor the elevator is currently at. You'll also need to decide how many pixels high each floor is, and convert the floor numbers to those height numbers (hint: Use multiplication).
|
|
|
|
|
![](images/spacer.gif) |
supadupamegaman
|
Posted: Wed Jan 09, 2013 1:19 pm Post subject: Re: Turing elevator floors help |
|
|
I have tried this, but the code does not work. What is wrong with this?
exit when elevator_pointy1 +50 = ybutton(1) or elevator_pointy1 + 50= ybutton(2)or elevator_pointy1 - 50 = ybutton(3)
(the length of my elevator is 100, so it would be half way when the elevator stops)
|
|
|
|
|
![](images/spacer.gif) |
|
|