Gui Button Help
Author |
Message |
jayman
|
Posted: Tue May 22, 2007 11:59 am Post subject: Gui Button Help |
|
|
OKay so this is a simple dice game....small flaws but thats okay...i want to import a GUI button....so what whenever i press the button the dice are rolled
rules:
if you role 7 or 11 on first roll you win....
if 7 or 11 is rolled after first roll you lose...
if you roll same number as your first roll..you win..............................winning roll is yellow..losing roll is red...otherwise green
[CODE]
setscreen ("graphics")
setscreen ("graphics:max;max")
drawfillbox (100,100,100+200,100+200,green)%%LEFT DIE
drawfillbox (400,100,400+200,100+200,green)%%RIGHT DIE
var count:=0
var t2:=0
loop
count:=count+1
drawfillbox (100,100,100+200,100+200,green)%%LEFT DIE
drawfillbox (400,100,400+200,100+200,green)%%RIGHT DIE
var roll :string
var number :int
randint(number,1,6)
var roll2 :string
var number2 :int
randint(number2,1,6)
var t:int
t:=number+number2
put t
if number=1 then
drawfilloval (500,200,15,15,black)
elsif number=2 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
elsif number=3 then
drawfilloval (500,200,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (440,130,15,15,black)
elsif number=4 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
elsif number=5 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (500,200,15,15,black)
elsif number=5 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
elsif number=6 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
end if
if
number2=1 then
drawfilloval (200,200,15,15,black)
elsif number2=2 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
elsif number2=3 then
drawfilloval (140,130,15,15,black)
drawfilloval (200,200,15,15,black)
drawfilloval (260,270,15,15,black)
elsif number2=4 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
elsif number2=5 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (200,200,15,15,black)
elsif number2=6 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (140,200,15,15,black)
drawfilloval (260,200,15,15,black)
end if
if t2=t and count>1 then
locate(1,50)
put "YOU WIN"
drawfillbox (400,100,400+200,100+200,yellow)
if number=1 then
drawfilloval (500,200,15,15,black)
elsif number=2 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
elsif number=3 then
drawfilloval (500,200,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (440,130,15,15,black)
elsif number=4 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
elsif number=5 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (500,200,15,15,black)
elsif number=5 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
elsif number=6 then
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
end if
drawfillbox (100,100,100+200,100+200,yellow)
if
number2=1 then
drawfilloval (200,200,15,15,black)
elsif number2=2 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
elsif number2=3 then
drawfilloval (140,130,15,15,black)
drawfilloval (200,200,15,15,black)
drawfilloval (260,270,15,15,black)
elsif number2=4 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
elsif number2=5 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (200,200,15,15,black)
elsif number2=6 then
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (140,200,15,15,black)
drawfilloval (260,200,15,15,black)
end if
exit
end if
if t=7 and count=1 then
locate(1,50)
put"YOU WIN"
drawfillbox (100,100,100+200,100+200,yellow)
drawfillbox (400,100,400+200,100+200,yellow)
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (500,200,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (440,130,15,15,black)
exit
elsif t=7 and count>1 then
locate (1,50)
put "YOU LOSE"
drawfillbox (100,100,100+200,100+200,red)
drawfillbox (400,100,400+200,100+200,red)
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (500,200,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (440,130,15,15,black)
exit
elsif t=11 and count=1 then
locate(1,50)
put"YOU WIN"
drawfillbox (100,100,100+200,100+200,yellow)
drawfillbox (400,100,400+200,100+200,yellow)
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (140,200,15,15,black)
drawfilloval (260,200,15,15,black)
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
exit
elsif t=11 and count>1 then
locate (1,50)
put "YOU LOSE"
drawfillbox (100,100,100+200,100+200,red)
drawfillbox (400,100,400+200,100+200,red)
drawfilloval (140,130,15,15,black)
drawfilloval (260,270,15,15,black)
drawfilloval (260,130,15,15,black)
drawfilloval (140,270,15,15,black)
drawfilloval (140,200,15,15,black)
drawfilloval (260,200,15,15,black)
drawfilloval (440,130,15,15,black)
drawfilloval (560,270,15,15,black)
drawfilloval (560,130,15,15,black)
drawfilloval (440,270,15,15,black)
drawfilloval (440,200,15,15,black)
drawfilloval (560,200,15,15,black)
end if
if count=1 then
t2:=t
end if
delay(1000)
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Albrecd
|
Posted: Tue May 22, 2007 1:38 pm Post subject: Re: Gui Button Help |
|
|
Well, you could go about this in 2 ways:
The first way would be to use Turing's built-in GUI to make the button using the following syntax:
code: |
import GUI
var button1name := GUI.CreateButton (<x position>, <y position>, <horizontal padding>, "<string to appear on button>", <procedure run by button>)
var button2name := GUI.CreateButton (<x>, <y>, <padx>, "<text>", GUI.Quit)
loop
exit when GUI.ProcessEvent
end loop
|
The procedure will be run every time button1 is pressed, and the GUI loop will end when button 2 is pressed.
The second way would be to make your own Button by drawing a box and using Mouse.Where to determine if it was clicked on. |
|
|
|
|
|
Geostigma
|
Posted: Tue May 22, 2007 6:27 pm Post subject: RE:Gui Button Help |
|
|
Omg... Turing's GUI made me want to cut my self. Better to just use mouse.where |
|
|
|
|
|
|
|