Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon
Author |
Message |
cam_1011
|
Posted: Fri May 29, 2009 10:26 am Post subject: Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon |
|
|
What is it you are trying to achieve?
A Menu that would allow the user to click a button to go to a blackjack game or the other button to go to a poker game
What is the problem you are having?
I dont know how to make the program so when I click blackjack, it will read my settings and use my variables to run it
Describe what you have tried to solve this problem
I have looked at many menu options, tried putting all the blackjack information in the blackjack main procedure which it didnt want
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
import GUI
setscreen ("grpahics: 300;125")
procedure blackjack
put" You have selected blackjack"
delay(2000)
cls
end blackjack
procedure poker
end poker
var button1: int :=GUI.CreateButton(25,25,0,"Blackjack",blackjack)
var button2: int :=GUI.CreateButton(300,25,0,"Poker",poker)
loop
if GUI.ProcessEvent then
end if
end loop
%These are the variables used in the blackjack game
var points, cpoint : int
var card1, card2, card3, card4, card5, cardc1, cardc2, cardc3, cardc4, cardc5 : int
var name : string
var choice, temp, total, money, bet2, win, num1, under21, totalc, num2, num3, num4, num5, num6, shuffle : int
var choice2, choice3, choice4, choice5, choice6, choice7, col1, col2, col3, col4, col5 : string
var key : array char of boolean
var time2 : string
var nameTextField, addressTextField : int
var cardq : int
View.Set ("graphics:350;300")
%setting variables with default values
card1 := 0
card2 := 0
card3 := 0
card4 := 0
card5 := 0
cardc1 := 0
cardc2 := 0
cardc3 := 0
cardc4 := 0
cardc5 := 0
choice2 := "s"
choice3 := "n"
choice4 := "s"
choice4 := "s"
choice5 := "s"
under21 := 0
end if
%money to start off with
money := 1000
% These are procedure for blackjack game
%Card Generator for computer
procedure cardai (var num : int)
randint (num, 1, 10)
temp := num
end cardai
%Card Generator for user
procedure card (var num : int)
randint (num, 1, 10)
if num = 1 then
num := 11
end if
temp := num
end card
%Computer AI
procedure computerai
cardai (cardc1)
cardc1 := temp
cardai (cardc2)
cardc2 := temp
totalc := cardc1 + cardc2
if totalc <= 16 then
cardai (cardc3)
cardc3 := temp
totalc := totalc + cardc3
if totalc <= 16 then
cardai (cardc4)
cardc4 := temp
totalc := totalc + cardc4
if totalc <= 16 then
cardai (cardc5)
cardc5 := temp
totalc := totalc + cardc5
end if
end if
end if
cpoint := totalc
end computerai
%match procedure
procedure match
cls
if points > 21 and card1 = 11 then
card1 := 1
put "Changed your ace to 1"
put "Your total is now: " ..
total := card1 + card2 + card3 + card4 + card5
put total
put "Would you like to hit or stand?"
get choice7
if choice7 = "h" or choice7 = "H" then
if card3 = 0 then
card (card3)
card3 := temp
total := total + card3
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card4 = 0 then
card (card4)
card4 := temp
total := total + card4
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card5 = 0 then
card (card5)
card5 := temp
total := total + card5
points := total
put "Your total is now "
put total
delay (1500)
match
return
end if
else
match
return
end if
elsif points > 21 and card2 = 11 then
card2 := 1
put "Changed your ace to 1"
put "Your total is now: " ..
total := card1 + card2 + card3 + card4 + card5
put total
put "Would you like to hit or stand?"
get choice7
if choice7 = "h" or choice7 = "H" then
if card3 = 0 then
card (card3)
card3 := temp
total := total + card3
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card4 = 0 then
card (card4)
card4 := temp
total := total + card4
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card5 = 0 then
card (card5)
card5 := temp
total := total + card5
points := total
put "Your total is now "
put total
delay (1500)
match
return
end if
else
match
return
end if
elsif points > 21 and card3 = 11 then
card3 := 1
put "Changed your ace to 1"
put "Your total is now: " ..
total := card1 + card2 + card3 + card4 + card5
put total
put "Would you like to hit or stand?"
get choice7
if choice7 = "h" or choice7 = "H" then
if card3 = 0 then
card (card3)
card3 := temp
total := total + card3
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card4 = 0 then
card (card4)
card4 := temp
total := total + card4
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card5 = 0 then
card (card5)
card5 := temp
total := total + card5
points := total
put "Your total is now "
put total
delay (1500)
match
return
end if
else
match
return
end if
elsif points > 21 and card4 = 11 then
card4 := 1
put "Changed your ace to 1"
put "Your total is now: " ..
total := card1 + card2 + card3 + card4 + card5
put total
put "Would you like to hit or stand?"
get choice7
if choice7 = "h" or choice7 = "H" then
if card3 = 0 then
card (card3)
card3 := temp
total := total + card3
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card4 = 0 then
card (card4)
card4 := temp
total := total + card4
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card5 = 0 then
card (card5)
card5 := temp
total := total + card5
points := total
put "Your total is now "
put total
delay (1500)
match
return
end if
else
match
return
end if
elsif points > 21 and card5 = 11 then
card5 := 1
put "Changed your ace to 1"
put "Your total is now: " ..
total := card1 + card2 + card3 + card4 + card5
put total
put "Would you like to hit or stand?"
get choice7
if choice7 = "h" or choice7 = "H" then
if card3 = 0 then
card (card3)
card3 := temp
total := total + card3
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card4 = 0 then
card (card4)
card4 := temp
total := total + card4
points := total
put "Your total is now "
put total
delay (1500)
match
return
elsif card5 = 0 then
card (card5)
card5 := temp
total := total + card5
points := total
put "Your total is now "
put total
delay (1500)
match
return
end if
else
match
return
end if
end if
if cpoint > points and cpoint <= 21 then
win := 0
elsif points > cpoint and points <= 21 then
win := 1
elsif cpoint > 21 and points <= 21 then
win := 2
elsif points > 21 and cpoint <= 21 then
win := 3
elsif cpoint = points and cpoint <= 21 then
win := 4
elsif cpoint > 21 and points > 21 then
win := 5
end if
if win = 0 then
put "You lose, the dealer had " ..
put cpoint, ", you had " ..
put points
put "You lost " ..
put bet2, " dollars"
put "Do you wish to play another round?"
get choice6
cls
money := money - bet2
elsif win = 1 then
put "You win, the dealer had " ..
put cpoint, ", you had " ..
put points
put "You won " ..
put bet2, " dollars"
put "Do you wish to play another round?"
get choice6
cls
money := money + bet2
elsif win = 2 then
put "Dealer Busted"
put "You win, the dealer had " ..
put cpoint, ", you had " ..
put points
put "You won " ..
put bet2, " dollars"
put "Do you wish to play another round?"
get choice6
cls
money := money + bet2
elsif win = 3 then
put "You Busted"
put "You lost, the dealer had " ..
put cpoint, ", you had " ..
put points
put "You lost " ..
put bet2, " dollars"
put "Do you wish to play another round?"
get choice6
cls
money := money - bet2
elsif win = 4 then
put "Push, the dealer had " ..
put cpoint, ", you had " ..
put points
put "Do you wish to play another round?"
get choice6
cls
elsif win = 5 then
put "You and dealer both busted"
put "The dealer wins by default"
put "You lost " ..
put bet2, " dollars"
put "Do you wish to play another round?"
get choice6
cls
money := money - bet2
end if
cls
end match
%Card Playing
procedure jack
card (card1)
card1 := temp
card (card2)
card2 := temp
total := card1 + card2
if total = 21 then
cls
put "You Have 21"
delay (3000)
points := total
match
return
else
cls
put "The dealer's showing card is " ..
put cardc2
put "Your cards are:"
randint (num2, 1, 4)
if num2 = 1 then
color (12)
col1 := "H"
elsif num2 = 2 then
color (12)
col1 := "D"
elsif num2 = 3 then
color (255)
col1 := "S"
elsif num2 = 4 then
color (255)
col1 := "C"
end if
put "{" ..
put card1, col1, "} " ..
randint (num3, 1, 4)
if num3 = 1 then
color (12)
col2 := "H"
elsif num3 = 2 then
color (12)
col2 := "D"
elsif num3 = 3 then
color (255)
col2 := "S"
elsif num3 = 4 then
color (255)
col2 := "C"
end if
put "{" ..
put card2, col2, "}"
color (255)
put "Your total is: " ..
put total
if total <= 21 then
put "Would you like to hit or stand?"
get choice3
else
points := total
end if
end if
if choice3 = "h" or choice3 = "H" then
card (card3)
card3 := temp
total := total + card3
if total = 21 then
cls
put "You Have 21"
delay (3000)
points := total
match
return
else
cls
put "The dealer's showing cards are " ..
put cardc2, ", " ..
put cardc3
put "Your cards are:"
if num2 = 1 then
color (12)
elsif num2 = 2 then
color (12)
elsif num2 = 3 then
color (255)
elsif num2 = 4 then
color (255)
end if
put "{" ..
put card1, col1, "} " ..
if num3 = 1 then
color (12)
elsif num3 = 2 then
color (12)
elsif num3 = 3 then
color (255)
elsif num3 = 4 then
color (255)
end if
put "{" ..
put card2, col2, "} " ..
randint (num4, 1, 4)
if num4 = 1 then
color (12)
col3 := "H"
elsif num4 = 2 then
color (12)
col3 := "D"
elsif num4 = 3 then
color (255)
col3 := "S"
elsif num4 = 4 then
color (255)
col3 := "C"
end if
put "{" ..
put card3, col3, "} "
color (255)
put "Your total is: " ..
put total
if total <= 21 then
put "Would you like to hit or stand?"
get choice4
else
points := total
match
return
end if
end if
elsif choice3 = "s" or choice3 = "S" then
points := total
match
return
end if
if choice4 = "h" or choice4 = "H" then
card (card4)
card4 := temp
total := total + card4
if total = 21 then
cls
put "You Have 21"
delay (3000)
points := total
match
return
else
cls
put "The dealer's showing cards are " ..
put cardc2, ", " ..
put cardc3, ", " ..
put cardc4
put "Your cards are:"
if num2 = 1 then
color (12)
elsif num2 = 2 then
color (12)
elsif num2 = 3 then
color (255)
elsif num2 = 4 then
color (255)
end if
put "{" ..
put card1, col1, "} " ..
if num3 = 1 then
color (12)
elsif num3 = 2 then
color (12)
elsif num3 = 3 then
color (255)
elsif num3 = 4 then
color (255)
end if
put "{" ..
put card2, col2, "} " ..
if num4 = 1 then
color (12)
elsif num4 = 2 then
color (12)
elsif num4 = 3 then
color (255)
elsif num4 = 4 then
color (255)
end if
put "{" ..
put card3, col3, "} " ..
randint (num5, 1, 4)
if num5 = 1 then
color (12)
col4 := "H"
elsif num5 = 2 then
color (12)
col4 := "D"
elsif num5 = 3 then
color (255)
col4 := "S"
elsif num5 = 4 then
color (255)
col4 := "C"
end if
put "{" ..
put card4, col4, "} "
color (255)
put "Your total is: " ..
put total
if total <= 21 then
put "Would you like to hit or stand?"
get choice3
else
points := total
end if
end if
elsif choice4 = "s" or choice4 = "S" then
points := total
match
return
end if
if choice5 = "h" or choice5 = "H" then
card (card4)
card4 := temp
total := total + card4
if total = 21 then
cls
put "You Have 21"
delay (3000)
points := total
match
return
else
cls
put "The dealer's showing cards are " ..
put cardc2, ", " ..
put cardc3, ", " ..
put cardc4, ", " ..
put cardc5
put "Your cards are:"
if num2 = 1 then
color (12)
elsif num2 = 2 then
color (12)
elsif num2 = 3 then
color (255)
elsif num2 = 4 then
color (255)
end if
put "{" ..
put card1, col1, "} " ..
if num3 = 1 then
color (12)
elsif num3 = 2 then
color (12)
elsif num3 = 3 then
color (255)
elsif num3 = 4 then
color (255)
end if
put "{" ..
put card2, col2, "} " ..
if num4 = 1 then
color (12)
elsif num4 = 2 then
color (12)
elsif num4 = 3 then
color (255)
elsif num4 = 4 then
color (255)
end if
put "{" ..
put card3, col3, "} " ..
if num5 = 1 then
color (12)
elsif num5 = 2 then
color (12)
elsif num5 = 3 then
color (255)
elsif num5 = 4 then
color (255)
end if
put "{" ..
put card4, col4, "} " ..
randint (num6, 1, 4)
if num6 = 1 then
color (12)
col5 := "H"
elsif num6 = 2 then
color (12)
col5 := "D"
elsif num6 = 3 then
color (255)
col5 := "S"
elsif num6 = 4 then
color (255)
col5 := "C"
end if
put "{" ..
put card5, col5, "}"
color (255)
points := total
match
return
end if
elsif choice5 = "s" or choice5 = "S" then
points := total
match
return
end if
end jack
%Betting system
procedure bet
if money <= 0 then
end if
put "You have " ..
put money, " dollars left."
put "How much would you like to bet?"
end bet
%Game start
loop
computerai
bet
get bet2
if bet2 > money then
bet2 := money
end if
jack
end loop
Please specify what version of Turing you are using
4.1.1
Description: |
This is what I have tried and this is all the code in this post just in a attached file |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Final.t |
Filesize: |
14.15 KB |
Downloaded: |
78 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
BigBear
|
Posted: Fri May 29, 2009 3:08 pm Post subject: RE:Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon |
|
|
Grade 12 and no procedure/ functions and using GUI :S
|
|
|
|
|
![](images/spacer.gif) |
Kharybdis
![](http://compsci.ca/v3/uploads/user_avatars/111642592477ec7e78e574.gif)
|
Posted: Fri May 29, 2009 8:43 pm Post subject: RE:Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon |
|
|
make your own button using pictures and make it so when the mouse hovers over the button and you click on it, it goes to a blackjack procedure or poker procedure.
but seriously.. no procedures or functions?
|
|
|
|
|
![](images/spacer.gif) |
TheGuardian001
|
Posted: Fri May 29, 2009 11:32 pm Post subject: Re: Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon |
|
|
He has procedures. you just can't see them because he tore out the syntax tags.
To answer your question though, since you're using procedures for the rest of the code, is there any reason you aren't just calling the procedures inside procedure blackjack?
code: |
proc DealCard
%Do stuff
end DealCard
proc blackjack
DealCard
%do stuff
end blackjack
|
Calling blackjack calls the other needed procedures, and the game runs. Of course, using your code, this would result in errors, since you have the procedures for the game put after the main blackjack procedure. either rearrange your code or look into the forward and body commands, which allow you to create a procedure but define the contents later.
|
|
|
|
|
![](images/spacer.gif) |
cam_1011
|
Posted: Mon Jun 01, 2009 9:18 am Post subject: RE:Turing Menu Help, Button Interface... Gr 12 project, need help please...due soon |
|
|
thanks for the help guys
|
|
|
|
|
![](images/spacer.gif) |
|
|