Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
elevator help
Author Message
iop

Posted: Sun Aug 29, 2004 10:12 pm   Post subject: elevator help

using the fromTopToMiddle procedure if a person clicks on the middle button while the elevator is at the top, I want the elevator to go down to the middle. how can i do this?

Quote:
var x, y, b : int

proc fromTopToMiddle
drawfillbox (maxx div 2 - 22, 3, maxx div 2 + 22, 197, white)
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, red)
for decreasing up : 150 .. 80
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, white)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, red)
delay (10)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, white)
end for
drawfillbox (maxx div 2 - 20, 195, maxx div 2 + 20, 155, red)
end fromTopToMiddle

proc fromMiddleToTop
drawfillbox (maxx div 2 - 22, 3, maxx div 2 + 22, 197, white)
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, red)
for up : 80 .. 150
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, white)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, red)
delay (10)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, white)
end for
drawfillbox (maxx div 2 - 20, 195, maxx div 2 + 20, 155, red)
end fromMiddleToTop

proc fromGroundToMiddle
drawfillbox (maxx div 2 - 22, 3, maxx div 2 + 22, 197, white)
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, red)
for up : 0 .. 80
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, white)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, red)
delay (10)
drawfillbox (maxx div 2 - 20, 5 + up + 40, maxx div 2 + 20, 5 + up, white)
end for
drawfillbox (maxx div 2 - 20, 125, maxx div 2 + 20, 85, red)
end fromGroundToMiddle

for drawing : 23 .. 25
drawline (maxx div 2 - drawing, 0, maxx div 2 + drawing, 0, black)
drawline (maxx div 2 - drawing, 1, maxx div 2 + drawing, 1, black)
drawline (maxx div 2 - drawing, 2, maxx div 2 + drawing, 2, black)
drawline (maxx div 2 - drawing, 0, maxx div 2 - drawing, 200, black)
drawline (maxx div 2 - drawing, 0, maxx div 2 - drawing, 200, black)
drawline (maxx div 2 - drawing, 0, maxx div 2 - drawing, 200, black)
drawline (maxx div 2 + drawing, 0, maxx div 2 + drawing, 200, black)
drawline (maxx div 2 + drawing, 0, maxx div 2 + drawing, 200, black)
drawline (maxx div 2 + drawing, 0, maxx div 2 + drawing, 200, black)
drawline (maxx div 2 - drawing, 198, maxx div 2 + drawing, 198, black)
drawline (maxx div 2 - drawing, 199, maxx div 2 + drawing, 199, black)
drawline (maxx div 2 - drawing, 200, maxx div 2 + drawing, 200, black)
end for
drawfillbox (maxx div 2 - 20, 45, maxx div 2 + 20, 5, red)
drawfillbox (390, 160, 400, 170, blue)
locate (14, 45)
put "Call button."
drawfillbox (390, 98, 400, 108, blue)
locate (18, 45)
put "Call button."
drawfillbox (maxx - 10, 10, maxx - 40, 40, black)
locate (22, 76)
put "Exit"

loop
mousewhere (x, y, b)
if x >= 390 and x <= 400 and y >= 98 and y <= 108 and b = 1 then
fromGroundToMiddle
elsif x >= 390 and x <= 400 and y >= 160 and y <= 170 and b = 1 then
fromMiddleToTop
end if
exit when x >= maxx - 40 and x <= maxx - 10 and y >= 10 and y <= 40 and b = 1
end loop

AsianSensation

Posted: Sun Aug 29, 2004 10:49 pm   Post subject: (No subject)

you need to have a variable to keep track of your current position. Something like this could help:

 code: var pos : string proc fromTopToMiddle         ...         pos := "Middle" end fromTopToMiddle proc fromMiddleToTop         ...         pos := "Top" end fromMiddleToTop proc fromGroundToMiddle         ...         pos := "Middle" end fromGroundToMiddle

and when you are using your if statements, you have to check to see the current position of your elevator. Then depends on the position, you call the needed procedure.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: