Page 1 of 1

Need urgen help as soon as possible on Casino Game

Posted: Fri Nov 17, 2006 5:56 pm
by C_daley98
I have to make a casino game called craps. i have to have seperate procedures for main page, game page, dice , win/lose but i have the dice provcedure working but i can't check if the dice add up to 7 in the procedure called WinLose is there anyway to use the variable in both procedures and still have it equal the same number. Heres what i have so far if u could help that would be good of u.

randomize

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure Titlepage

var font1, font2 : int % font
var x, y, button, buttonnumber, buttonupdown : int
font1 := Font.New ("Alba Super:40")
font2 := Font.New ("Alba Matter:25")
drawfill (10, 10, 255, 255)
Font.Draw ("Welcome to Craps!!", 130, 330, font1, 55) % title

Font.Draw ("Play Game", 250, 250, font2, 55) % Displays Play Game tab
Font.Draw ("Instruction", 250, 200, font2, 55) % Displays the instruction tab
Font.Draw ("Exit", 250, 150, font2, 55) % Displays the exit tab
loop
mousewhere (x, y, button)
buttonwait ("down", x, y, buttonnumber, buttonupdown)


if x > 250 and x < 410 and y > 240 and y < 290 then % checks if play button is pressed
cls
exit
elsif x > 250 and x < 410 and y > 190 and y < 223 then % check if instruction button is pressed
cls
drawfill (10, 100, 255, 255) % makes background black

color (55)
colorback (255)
put skip % Displays the rules of the game
put "The game is simple, all you have to have is luck."
delay (3000) %%%%%%change to 3000
put skip
put "On your first roll, if you get a 7 or 11, you win!"
put "But if you get 2 or 12 on the first roll, you lose."
put "If you get anything else, you roll again."
delay (7000) %%%%%%%change to 7000
put skip
put "On your subsequent rolls, you have to get the same number as your first roll."
put "But if you get a 7, you lose! :("
delay (1000)
Font.Draw ("Play Game", 250, 100, font2, 14) % Displays Play Game tab


buttonwait ("down", x, y, buttonnumber, buttonupdown)
if x > 250 and x < 410 and y > 80 and y < 130 then % if play button is pressed in the instruction menu starts game
cls
exit
end if


end if
end loop

end Titlepage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Titlepage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure Gamepage
var money : int := 100
var bet : int := 50
var x, y, button, buttonnumber, buttonupdown : int

drawfill (10, 10, 255, 255)

drawline (0, 350, 650, 350, 14)
color (14)
colorback (255)
locate (2, 2)
put "MONEY: ", money

locate (7, 4)
put "Place Bet:"
drawbox (0, 190, 150, 305, 14) % box around the betting section

drawbox (10, 235, 35, 255, 14) % plus box
drawline (23, 238, 23, 250, 14) % middle line on plus sign
drawline (15, 243, 30, 243, 14) % line cross through

drawbox (110, 235, 140, 255, 14) % minus box
drawline (120, 245, 130, 245, 14) % minus sign

loop

locate (10, 8)
colorback (255)
put bet, " " ..

locate (12, 8)
put "BET" ..

drawbox (50, 200, 86, 230, 14)
buttonwait ("down", x, y, buttonnumber, buttonupdown)

if x > 10 and x < 35 and y > 235 and y < 255 then
bet := bet + 1
elsif x > 110 and x < 140 and y > 235 and y < 255 then
bet := bet - 1
end if

%%%%%%%%%%%%Stops number from going negative
if bet = 0 then
bet := bet + 1
%%%%%%%%%%%%Stops number from going over users money
elsif bet = money then
bet := bet - 1

end if

if x > 50 and x < 80 and y > 200 and y < 220 then
money := money - bet
end if

if money <= 0 then
money := 0
elsif money >= money then
money := money
end if

color (14)
colorback (255)
locate (2, 2)
put "MONEY: ", money

exit when x > 50 and x < 80 and y > 200 and y < 220

end loop


end Gamepage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Gamepage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Draws dice and makes dots move
procedure Dice
var num1, num2 : int
var count : int := 0
var totaldot : int := 0
var font3 : int

font3 := Font.New ("Vineta BT:10")

loop

randint (num1, 1, 6)

delay (200)

drawfillbox (200, 200, 300, 300, 0) %%% die on the left

drawfillbox (400, 200, 500, 300, 0) %%% die on the right


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Dice 1
if num1 = 1 then
drawfilloval (250, 250, 10, 10, 255) % middle dot
elsif num1 = 2 then
drawfilloval (280, 280, 10, 10, 255) % top right dot
drawfilloval (220, 220, 10, 10, 255) % bottom left dot
elsif num1 = 3 then
drawfilloval (280, 280, 10, 10, 255) % top right dot
drawfilloval (220, 220, 10, 10, 255) % bottom left dot
drawfilloval (250, 250, 10, 10, 255) % middle dot
elsif num1 = 4 then
drawfilloval (280, 280, 10, 10, 255) % top right dot
drawfilloval (220, 220, 10, 10, 255) % bottom left dot
drawfilloval (220, 280, 10, 10, 255) % top left dot
drawfilloval (280, 220, 10, 10, 255) % bottom right dot
elsif num1 = 5 then
drawfilloval (280, 280, 10, 10, 255) % top right dot
drawfilloval (280, 220, 10, 10, 255) % bottom right dot
drawfilloval (220, 220, 10, 10, 255) % bottom left dot
drawfilloval (220, 280, 10, 10, 255) % top left dot
drawfilloval (250, 250, 10, 10, 255) % middle dot
elsif num1 = 6 then
drawfilloval (220, 220, 10, 10, 255) % bottom left dot
drawfilloval (280, 220, 10, 10, 255) % bottom right dot
drawfilloval (220, 250, 10, 10, 255) % left middle dot
drawfilloval (280, 250, 10, 10, 255) % right middle dot
drawfilloval (280, 280, 10, 10, 255) % top right dot
drawfilloval (220, 280, 10, 10, 255) % top left dot
end if


randint (num2, 1, 6)
count := count + 1

if num2 = 1 then
drawfilloval (450, 250, 10, 10, 255) % middle dot
elsif num2 = 2 then
drawfilloval (420, 220, 10, 10, 255) % bottom left
drawfilloval (480, 280, 10, 10, 255) % top right
elsif num2 = 3 then
drawfilloval (420, 220, 10, 10, 255) % bottom left
drawfilloval (480, 280, 10, 10, 255) % top right
drawfilloval (450, 250, 10, 10, 255) % middle dot
elsif num2 = 4 then
drawfilloval (420, 280, 10, 10, 255) % top left
drawfilloval (480, 280, 10, 10, 255) % top right
drawfilloval (420, 220, 10, 10, 255) % bottom left
drawfilloval (480, 220, 10, 10, 255) % bottom right
elsif num2 = 5 then
drawfilloval (420, 220, 10, 10, 255) % bottom left
drawfilloval (420, 280, 10, 10, 255) % top left
drawfilloval (480, 220, 10, 10, 255) % bottom right
drawfilloval (480, 280, 10, 10, 255) % top right
drawfilloval (450, 250, 10, 10, 255) % middle dot
elsif num2 = 6 then
drawfilloval (420, 220, 10, 10, 255) % bottom left
drawfilloval (420, 250, 10, 10, 255) % middle left
drawfilloval (420, 280, 10, 10, 255) % top left
drawfilloval (480, 220, 10, 10, 255) % bottom right
drawfilloval (480, 250, 10, 10, 255) % middle right
drawfilloval (480, 280, 10, 10, 255) % top right
end if

exit when count = 20
end loop

end Dice
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
procedure Winlose

var x, y, button, buttonnumber, buttonupdown : int

var num1, num2 : int
var count : int := 0
var totaldot : int := 0
var font3 : int

font3 := Font.New ("Vineta BT:10")
loop

drawbox (10, 100, 100, 150, 14)

locate (18, 5)
put "ROLL" ..

buttonwait ("down", x, y, buttonnumber, buttonupdown)

if x > 10 and x < 100 and y > 100 and y < 150 then
Dice


end if
end loop
end Winlose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



Winlose

Archived topic from Iceteks, old topic ID:4618, old post ID:36769

Need urgen help as soon as possible on Casino Game

Posted: Fri Nov 17, 2006 7:10 pm
by manadren_it
I'm not familiar with Turing, but if you want to use a variable from one procedure in another you need to either (1) pass the variable as an argument when calling the second procedure in the first or (2) use a global variable. As it stands though, I don't see where any of these procedures are being called.

Perhaps I should just step aside and let people who actually know Turing answer the question.

Archived topic from Iceteks, old topic ID:4618, old post ID:36770