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

Username:   Password: 
 RegisterRegister   
 multi button
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
needhelp




PostPosted: Sat Jan 15, 2005 4:43 pm   Post subject: multi button

hey ppl i am tryin 2 build ma trafic light but i got one problem....i made a button dat turns on da traffic light but i am tryin 2 use da same button 2 turn off da light ...but i dont noe how 2 do it ...can sum1 plzzz help


setscreen ("graphics:vga")

%drawing my traffic
drawfillbox (420, 30, 580, 390, black)
drawfilloval (500, 320, 40, 40, grey)
drawfilloval (500, 210, 40, 40, grey)
drawfilloval (500, 100, 40, 40, grey)

%drawing the buttons that will be used to operate the traffic lights

drawfillbox (280, 260, 380, 300, red)
drawfillbox (280, 190, 380, 230, yellow)
drawfillbox (280, 120, 380, 160, green)

%turning on the trafic light
var x, y, bnum, bud : int
var gr := 0
loop
buttonwait ("down", x, y, bnum, bud)
if x >= 280 and x <= 380 and y >= 260 and y <= 300 then
drawfilloval (500, 320, 40, 40, red)
elsif x >= 280 and x <= 380 and y >= 190 and y <= 230 then
drawfilloval (500, 210, 40, 40, yellow)
elsif x >= 280 and x <= 380 and y >= 120 and y <= 160 then
drawfilloval (500, 100, 40, 40, green)
elsif gr =
drawfilloval (500, 100, 40, 40, grey)
end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Jan 15, 2005 6:58 pm   Post subject: (No subject)

1.)
[ syntax="turing"][ /syntax] tags please.

2.)
Your question and your code show different things. Your question says you have one button, your code says you have three. Which do I believe? I'll go with the code. To solve the problem, simply move the code for drawing your traffic light inside the main loop, before the drawing of the red, yellow, or green ovals.

-Cervantes
needhelp




PostPosted: Sat Jan 15, 2005 8:04 pm   Post subject: turing

i noe dere r 3 buttons but i dont get how 2 mkae any of dem work as a multi button like now if i go on any of dem it turns on da traffic light but wat if i wanna press da same button and turn it off...u noe like on and off button
Leftover




PostPosted: Sat Jan 15, 2005 8:15 pm   Post subject: (No subject)

It might also help if you used proper english and grammar...
needhelp




PostPosted: Sat Jan 15, 2005 8:19 pm   Post subject: turing

ah come on man....dis is a frickin post ....wat u expect me 2 do ....rtie a essay or wat....jst plzz help me ...all im tryin 2 do is ...make each button work as a multi button mode...if u would jst copy and paste da code 2 turin u would understand wat im tryin 2 say...so i want for example da red button 2 turn on da red light onz i press it ...den if i press it again i want it 2 turn it off...Smile Very Happy
Leftover




PostPosted: Sat Jan 15, 2005 8:22 pm   Post subject: (No subject)

but you're going out of your way to make it harder for me to read what you're typing, which makes me hesitant to even copy the code with the feeling that it is spelt the same way and I'd have to fix 50 errors before I could help.
needhelp




PostPosted: Sat Jan 15, 2005 8:25 pm   Post subject: (No subject)

no man da code is fyne ...wats wrong wid u ...like come on all u gotta do is check da code and give me sum advice i would really appreciate ur help ... Embarassed
Cervantes




PostPosted: Sat Jan 15, 2005 8:26 pm   Post subject: (No subject)

Leftover wrote:
It might also help if you used proper english and grammar...

needhelp wrote:
ah come on man....dis is a frickin post ....wat u expect me 2 do ....rtie a essay or wat

Leftover's right. And no, you don't have to write an essay; know, however, that proper spelling and grammer makes things easier to read and makes us more willing to help you. For example, "the" is not spelled with a 'd'.

And, for your question, use if statements. If the top light is selected then, if the light is on, draw it in grey, elsif it is off, draw it in red, eslif the middle light is selected...
Sponsor
Sponsor
Sponsor
sponsor
needhelp




PostPosted: Sat Jan 15, 2005 8:30 pm   Post subject: (No subject)

so ...ok proper spelling...ok so i have to write if something is on then drawoval and if something is off then drawoval and give it a different colour ...but do i have to give variables and how do i say if sumthing is off or on...do i use 1 and o??
Cervantes




PostPosted: Sat Jan 15, 2005 8:34 pm   Post subject: (No subject)

Yes, you should use a variable to store whether the light is on or off. I would recommend using a boolean variable, but you can use string, int, or real. It doesn't matter.
Your other option is to not use variables, but instead use whatdotcolour. That way might take less lines and might even be easier, but using variables will teach you more. Use variables.
-Cervantes
needhelp




PostPosted: Sat Jan 15, 2005 8:39 pm   Post subject: oh

oh i never learned the whatdotcolour command...how does that work??
Cervantes




PostPosted: Sat Jan 15, 2005 8:43 pm   Post subject: (No subject)

It doesn't. Use variables. You ned to understand the basics of programming (that includes techniques and ideas, not just syntax) before you start learning the library's advanced functions.
needhelp




PostPosted: Sat Jan 15, 2005 8:46 pm   Post subject: (No subject)

yea i know what you saying but i started not even 3 weeks ago ...we had to do it fast and learn stuff on our own..so yea ok i gave each button a variable ...for the red button the variable is "re" for yellow its "ye" and for green its "gr" so after i do that how do i say if "re" is off then draw somthing??
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  [ 13 Posts ]
Jump to:   


Style:  
Search: