Thread: Craps Game

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    63

    Question Craps Game

    I'm having trouble understanding the game of craps. Specifically the part when the player rolls a 4,5,6,8,9, or 10 and how the points work and when the player stops rolling. If you roll a 7 on your 2nd roll do you still get the points from the first roll?

    "A player rolls two dice. Each die has six faces. These faces contain 1,2,3,4,5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated. If the sum is 7 or 11 on the first throw, the player wins. If the sum is 2,3, or 12 on the first throw (called “craps”), the player loses (i.e., the “house” wins). If the sum is 4,5,6,8,9, or 10 on the first throw, then that sum becomes the player’s “points.” To win, you must continue rolling the dice until you “make your points.” The player loses by rolling a 7 before making the points."

    Here is my code so far:

    Code:
    /*
    
    My name is Jack Trocinski
    
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h> 
    
    int main()
    {
        int diceI, diceII, S, dicesum;
        dicesum = 0;
        
        printf("CRAPS\n");
        printf("INSTRUCTIONS: Press S then Enter to begin the game.\n\n");
        
        scanf("%d", &S);
        
        srand(time(NULL));
          diceI = rand()%(6 - 1 + 1) + 1;
          printf ("You rolled a %d ", diceI);
          diceII = rand()%(6 - 1 + 1) + 1;
          printf ("and a %d. \n", diceII);
        
        dicesum = diceI + diceII;
        
        if (dicesum == 7)
            printf("You win!");
        else if (dicesum == 11)
            printf("You win!");
        else if (dicesum == 2)
            printf("You lose.");
        else if (dicesum == 3)
            printf("You lose.");
        else if (dicesum == 12)
            printf("You lose.");
        else
        {
            diceI = rand()%(6 - 1 + 1) + 1;
            printf ("You rolled a %d ", diceI);
            diceII = rand()%(6 - 1 + 1) + 1;
            printf ("and a %d. \n", diceII);
            dicesum = diceI + diceII + dicesum;
    
        }
        
        return 0;
    }
    Last edited by yacek; 10-08-2010 at 04:48 PM.

  2. #2
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,732
    >I'm having trouble understanding the game of craps. Specifically the part when the player rolls a 4,5,6,8,9, or 10 and how the points work and when the player stops rolling. If you roll a 7 on your 2nd roll do you still get the points from the first roll?
    You should really ask this question with your prof. He should know the answer for this question. I haven't played Craps Game sadly.

    ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    63
    LOL ssharish2005 me too! All good though, did some more reading on it and I think I figured out how it works :]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [freefps]Tactical Assault coders needed
    By Sickmind in forum Projects and Job Recruitment
    Replies: 4
    Last Post: 05-07-2010, 05:06 PM
  2. Please comment on my c++ game
    By MegaManZZ in forum Game Programming
    Replies: 10
    Last Post: 01-22-2008, 11:03 AM
  3. Craps Game
    By TWIXMIX in forum Game Programming
    Replies: 5
    Last Post: 06-12-2004, 07:47 PM
  4. HELP!wanting to make full screen game windowed
    By rented in forum Game Programming
    Replies: 3
    Last Post: 06-11-2004, 04:19 AM
  5. help with a craps game!
    By Jessie in forum C Programming
    Replies: 10
    Last Post: 10-16-2002, 09:19 AM