Computer Science Canada exit button |
Author: | nin [ Sun Dec 31, 2006 2:06 pm ] |
Post subject: | exit button |
i need help on my exit button because it doesnt work =/... so can anyone help me please >.<" n thank you anyway % Declaration Section var finished := false var rangex, rangey, button : int % Set screen mode and size setscreen ("graphics: 300;300") %Title procedure title cls locate (1, 16) put "Colours" end title %Introduction procedure introduction title locate (3, 1) put "Click a square to find out" put "what colour it is." end introduction %Display procedure display % Light blue square drawfillbox (0, 120, 95, 220, 101) mousewhere (rangex, rangey, button) if button = 1 then if rangex >= 0 and rangex <= 95 and rangey >= 120 and rangey <= 220 then locate (13, 1) put "Selected square: Light blue." put " " delay (1000) finished := true else locate (13, 1) put "You clicked at : ", rangex, ", ", rangey put " " end if end if % Yellow square drawfillbox (100, 120, 195, 220, yellow) mousewhere (rangex, rangey, button) if button = 1 then if rangex >= 100 and rangex <= 195 and rangey >= 120 and rangey <= 220 then locate (13, 1) put "Selected square: Yellow." put " " delay (1000) finished := true else locate (13, 1) put "You clicked at : ", rangex, ", ", rangey put " " end if end if % Black square drawfillbox (200, 120, 300, 220, 7) mousewhere (rangex, rangey, button) if button = 1 then if rangex >= 200 and rangex <= 300 and rangey >= 120 and rangey <= 220 then locate (13, 1) put "Selected square: Black." put " " delay (1000) finished := true else locate (13, 1) put "You clicked at : ", rangex, ", ", rangey end if end if %Exit button drawbox (205, 10, 100, 30, 3) locate (18, 18) put "EXIT" .. end display %Goodbye procedure goodBye locate (6, 5) put "Brought to you by: " locate (7, 20) put "Ninanori Agustin" end goodBye % Main program introduction loop display mousewhere (rangex, rangey, button) if button = 1 then exit when rangex >= 205 and rangex <= 100 and rangey >= 10 and rangey <= 30 else locate (14, 1) put "You clicked at : ", rangex, ", ", rangey end if end loop cls goodBye |
Author: | CodeMonkey2000 [ Sun Dec 31, 2006 3:15 pm ] | ||||
Post subject: | |||||
Please use code tags next time. it's [code ] inset code here[/code ] without the spaces. And your problem is:
|
Author: | BenLi [ Sun Dec 31, 2006 3:26 pm ] | ||
Post subject: | |||
you program doesn't look too big right now, but if you are going to create a bigger program, i suggest a buttontrue function, because small mistakes like that can really waste your time. This bit of code will help a lot in bigger programs with many buttons. ie.
|
Author: | CodeMonkey2000 [ Sun Dec 31, 2006 3:31 pm ] |
Post subject: | |
Or just make you own button class. |
Author: | nin [ Mon Jan 01, 2007 10:05 pm ] |
Post subject: | |
k thank you soo much for ur help =) |
Author: | BenLi [ Tue Jan 02, 2007 10:35 am ] |
Post subject: | |
spearmonkey2000: ...under the assumption that this user has knowledge of classes, which is doubtful based on the project he's undertaken. |