Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing elevator floors help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
supadupamegaman




PostPosted: 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



cs isp.t
 Description:

Download
 Filename:  cs isp.t
 Filesize:  5.96 KB
 Downloaded:  64 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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).
supadupamegaman




PostPosted: 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)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: