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

Username:   Password: 
 RegisterRegister   
 Need help i cant get this to work
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Eyy




PostPosted: Sat Jun 12, 2010 11:55 am   Post subject: Need help i cant get this to work

Ok so I have to create a program that simulates a car and a traffic light with 3 lights. I have to make a testing mode, where user can just click on and off for the buttons and the LED will light up, and i have to make a scenario mode, but thats not important right now.
(I attached the turing program, and I am using version 4.05)

Here's the problem, the homepage works fine, i run it and if i click anywhere but the Testing box it will say you didnt click on a box. Then if i click testing mode it goes to testing mode (with procedure). On testing mode clicking all the on/off button works fine. But heres my problem, the home button. If i click it, it brings me back to home, (but the way home is made in a procedure) for some reason when it redirects me to home, the program automatically goes to the procedure for testing mode, not the loop at the very bottom where it will let you pick testing mode again. Its kinda hard to explain, i tried shifting the codes and i worked for 2 hours on it but i cant get it to work properly.

Would appreciate it if i could get some help thanks.!

I cant attach for some reason so here's the code.




Turing:


<setscreen ("graphics")
var font1 :int
var font2 :int
var font3 :int
var font4 :int
var x, y, bnum, bud : int

font1 := Font.New ("century gothic:45")
font2 := Font.New ("century gothic:20")
font3 := Font.New ("century gothic:10")
font4 := Font.New ("century gothic:15:bold")


Font.Draw ("Culminating Activity",0,350,font1,black)
delay (750)
Font.Draw ("Programmed by me.", 5,315,font2,black)
delay (500)
Font.Draw ("Click the box and choose whether you want testing mode or scenario mode.", 5,260,font3,black)

Draw.FillBox (5,50,250,200, grey)
Draw.FillBox (275,50,520,200, grey)

Font.Draw ("Testing", 5,210,font3,black)
Font.Draw ("Scenario", 275,210,font3,black)

procedure homepage
Font.Draw ("Culminating Activity",0,350,font1,black)
delay (750)
Font.Draw ("Programmed by me.", 5,315,font2,black)
delay (500)
Font.Draw ("Click the box and choose whether you want testing mode or scenario mode.", 5,260,font3,black)

Draw.FillBox (5,50,250,200, grey)
Draw.FillBox (275,50,520,200, grey)

Font.Draw ("Testing", 5,210,font3,black)
Font.Draw ("Scenario", 275,210,font3,black)

end homepage


procedure test
    put "Welcome to the testing mode."
    delay (500)
    put "INSTRUCTIONS: Click the on or off button to simulate a traffic light and vehicle."
    Draw.FillBox (10,340,85,265,blue)
    Draw.FillBox (10,255,85,180,blue)
    Draw.FillBox (10,170,85,95,blue)
    Draw.FillBox (10,85,85,10,blue)
    Draw.FillBox (550,85,625,10,blue)
   
    Draw.FillBox (375,340,450,265,darkgrey)
    Draw.FillBox (375,255,450,180,darkgrey)
    Draw.FillBox (375,170,450,95,darkgrey)
    Draw.FillBox (375,85,450,10,darkgrey)
    Draw.FillBox (550,85,625,10,black)

    Font.Draw ("Stop", 95,265,font3,black)
    Font.Draw ("Caution", 95,180,font3,black)
    Font.Draw ("Go", 95,95,font3,black)
    Font.Draw ("Motor", 95,10,font3,black)
    Font.Draw ("OFF", 460,265,font3,black)
    Font.Draw ("OFF", 460,180,font3,black)
    Font.Draw ("OFF", 460,95,font3,black)
    Font.Draw ("OFF", 460,10,font3,black)
    Font.Draw ("Main Menu",550,90,font3,black)
   
    Draw.FillOval (265,300,35,35,grey)
    Draw.FillOval (265,215,35,35,grey)
    Draw.FillOval (265,130,35,35,grey)
    Draw.FillOval (265,45,35,35,grey)   
   
loop
    buttonwait ("down", x, y, bnum, bud)
    if x >= 10 and x <= 85 and y >= 265 and y <= 340 then
    Draw.FillOval (265,300,35,35,red)
    elsif x >= 375 and x <= 450 and y >= 265 and y <= 340 then
    Draw.FillOval (265,300,35,35,grey)
    elsif x >= 10 and x <= 85 and y >= 180 and y <= 255 then
    Draw.FillOval (265,215,35,35,yellow)
    elsif x >= 375 and x <= 450 and y >= 180 and y <= 255 then
    Draw.FillOval (265,215,35,35,grey)
    elsif x >= 10 and x <= 85 and y >= 95 and y <= 170 then
    Draw.FillOval (265,130,35,35,green)
    elsif x >= 375 and x <= 450 and y >= 95 and y <= 170 then
    Draw.FillOval (265,130,35,35,grey)
    elsif x >= 10 and x <= 85 and y >= 10 and y <= 85 then
    Draw.FillOval (265,45,35,35,black)
    elsif x >= 375 and x <= 450 and y >= 10 and y <= 85 then
    Draw.FillOval (265,45,35,35,grey)
    elsif x >= 550 and x <= 625 and y >= 10 and y <= 85 then
cls
homepage
    end if
end loop
end test


loop

buttonwait ("down", x, y, bnum, bud)
if x >= 5 and x <= 250 and y >= 50 and y <= 200 then
cls
test
else
Font.Draw ("You did not click a box. Try again.", 5,5,font4,red)   
end if

end loop>




NEW.t
 Description:
help

Download
 Filename:  NEW.t
 Filesize:  3.44 KB
 Downloaded:  78 Time(s)


NEW.t
 Description:
My program.

Download
 Filename:  NEW.t
 Filesize:  3.44 KB
 Downloaded:  79 Time(s)


NEW.t
 Description:

Download
 Filename:  NEW.t
 Filesize:  3.44 KB
 Downloaded:  95 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Cezna




PostPosted: Sat Jun 12, 2010 1:58 pm   Post subject: RE:Need help i cant get this to work

You attached it three times Very Happy

It doesn't recognize it if I click on scenario mode, and I don't understand the purpose of the lights and motor buttons.
Is it supposed to make sound or something?

If I go to test, then main, then scenario, it draws a grey circle between the buttons. Is this the problem you were reffering to?
If I click where the on/off buttons were in testing, it changes between grey and green, and if I click around for the other buttons, the yellow, red and black lights appear.

Clearly the problem is something to do with not clearing the screen properly.
It may have something to do with the buttonwait.
I never use it, instead I use Mouse.Where, so I don't know whether or not you are using it right, but I can't see what else it could be by looking through the code.
Eyy




PostPosted: Sat Jun 12, 2010 3:01 pm   Post subject: RE:Need help i cant get this to work

Nothing is supposed to happen haha, just the lights are supposed to go on and off thats it, but the Home button is kind of messed up and i dont know how to fix it. Run program, click test, click Main menu, and theres the problem, the if statements for the test mode come up instead of the loop for to button to redirect to test mode again.

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