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

Username:   Password: 
 RegisterRegister   
 Craps Dice Game Help!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mooonty




PostPosted: Mon Jan 13, 2014 5:40 pm   Post subject: Craps Dice Game Help!

What is it you are trying to achieve?
I am trying to finish up a craps dice game that I have been working on!


What is the problem you are having?
I have got the basic game down, but it keeps reassigning me a new "point" every roll.


Describe what you have tried to solve this problem
I have tried many things, and stil cannot get the answer!

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


<% NAME: Alex Montague
% PURPOSE: To create the game of craps in turing
% DATE: 12/17/2013

%Variable Decleration Section
var Dice1, Dice2, Total : int
var Bet : real
var Pot : real
var WantToPlay : string

forward procedure Start
forward procedure RollAgain

put "Do you want to roll? Yes or No " ..
get WantToPlay

if WantToPlay = "Yes" then
    Start
end if

if WantToPlay = "No" then
    cls
    put "Play again soon!"
end if

randomize
body procedure RollAgain
    loop
        randint (Dice1, 1, 6)
        randint (Dice2, 1, 6)
        Total := Dice1 + Dice2
        Pot := Pot + Bet
        put "Your point is ", Total

        if Total = 4 or Total = 5 or Total = 6 or Total = 8 or Total = 9 or Total = 10 or Total = 12 then
            put "Keep rolling"

        elsif Total = 7 or Total = 11 then
            put "You lose!"
            exit
        end if
    end loop
end RollAgain

body procedure Start
    loop
        Pot := 100
        exit when Pot <= 0
        put "You have $", Pot, " in the bank! "
        put "How much do you want to bet? " ..
        get Bet
        cls
        randint (Dice1, 1, 6)
        randint (Dice2, 1, 6)
        Total := Dice1 + Dice2
        put "You rolled a ", Total
        if Total = 7 or Total = 11 then
            put "You win!!"
            Pot := Pot + Bet
            put "You won ", Bet, " dollars!! "
            put "You now have ", Pot, " dollars!! "
        elsif
                Total = 2 or Total = 3 or Total = 12 then
            put "You lose!!"
            Pot := Pot - Bet
            put "You lost ", Bet, "  dollars!! "
            put "You now have ", Pot, " dollars!! "
        else
            RollAgain
        end if
    end loop
end Start

if Pot <= 0 then
    put "You're out of money!"
    put "Want to play again? (Yes or No)"
end if
>



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: