Thread: Blackjack

  1. #31
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    :)

    could i see your code after you finish your game..??
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  2. #32
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    Me? maybe. dunno.
    and it's not going very well right now. i had to make my own swap function for my card structure, and it's not working.

    i have this BASIC book that has a cool equation thing that gives the suit and value of a card from just one number. it seemed pretty cool but not very useful for a blackjack game.

    this is kinda what i have.
    Code:
    struct card
    {
       int value; //2 thru Ace
       int suit; //self explanatory.
       int score; //value in bj.
    };
    typedef card CARD;
    
    void swap(CARD x, CARD y);
    
    class Deck
    {
       private:
          int place; //what card the deck is on.
       public:
          CARD cards[51]; //52 cards. (you need 51 there cuz of 0 - 51 is 52 numbers.
          Deck();
          shuffle();
    //more stuff.
    };
    
    Deck::shuffle()
    {
       int j;
       for(int i = 0; i<52; i++)
       {
          j = random(52);
          swap(cards[i], cards[j]);
       }
    }
    
    swap(CARD x, CARD y)
    {
       CARD temp;
       //blah blah
       //here i set the values of x to temp
       //the values of y to x
       //and the values of temp to y
    }
    that's pretty much what i have.
    NOTE: it wasn't copied directly.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  3. #33
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    ???

    you have a chicken in your pants....?!???
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  4. #34
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65

    Yes. (and it hurts)

    Yep!
    im looking thru billions of posts on this board to try and figure out a way to fix my shuffle function.

    i was really gettin' into this project. I even made a FLOWCHART. *gasp*

    Un burro sabe mas que tu. Heh heh heh.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  5. #35
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    Me? maybe. dunno.
    and it's not going very well right now. i had to make my own swap function for my card structure, and it's not working.
    If the code is just like what you have written, I think the swap function isn't working because you are passing the cards by value. The swap function creates two new CARD variables, swaps them, then destroys them when the function is done. Change
    Code:
    void swap(CARD x, CARD y);
    to
    Code:
    void swap(CARD &x, CARD &y);
    Also, it should be cards[52] not cards[51]. The number sets aside the amount of memory to allocate, NOT the highest index. So cards[52] allocates memory for 52 cards numbered 0-51.

  6. #36
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    yah i figured that out that day my dad helped me. now im working on dealing out the cards. hopefully it will work. im kinda doing a text rpg and blackjack at the same time (but im working on blackjack more).
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  7. #37
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Thumbs up

    maybe there is a way to get the best of both worlds..

    i think it would be cool if you could incorporate blackjack in your RPG...


    or maybe an RPG inside your game of blackjack...?
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  8. #38
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    and i realized something...
    character numbers 3 thru 6 are the suits...yay!
    Brain: I wish I could teach u women. i don't think anyone can ('cept maybe a woman)
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  9. #39
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Question

    i don't think women can even teach women
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  10. #40
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    Quote Originally Posted by The Brain
    i don't think women can even teach women
    true dat.
    in this song on one of my CDs it says "play it back in slow motion so I may understand the complex infrastructure known as the female mind"

    here's code for the suit thing
    Code:
    #include <iostream.h>
    
    const char suit[4] = {3, 4, 5, 6};
    const char *rank[13] = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
    
    int main(void)
    {
    	for(int i=0; i<4; i++)
       {
       	for(int j=0; j<13; j++)
          {
          	cout<<suit[i]<<rank[j]<<" ";
          }
       }
       return 0;
    }
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  11. #41
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    will const char suit[4] = {3, 4, 5, 6}; work without using ' ' char notation

    ex:

    const char suit[4] = {'3', '4', '5', '6'};
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  12. #42
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >will const char suit[4] = {3, 4, 5, 6}; work without using ' ' char notation
    It will if your system prints the heart, diamond, club, and spade for values 3, 4, 5, and 6.
    My best code is written with the delete key.

  13. #43
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903
    outstanding.
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

  14. #44
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    If anybody is interested, here are a couple of classes I wrote last year sometime dealing with cards, deck of cards, and card hands. Among other useful methods, they are set up to print pretty pictures, well as pretty as ASCII art goes anyways! You guys are welcome to use them, just don't take credit for them lol The petter-color.h file is used for the colors so be sure to include it.

  15. #45
    VA National Guard The Brain's Avatar
    Join Date
    May 2004
    Location
    Manassas, VA USA
    Posts
    903

    Wink :)

    code looks really good.. a bit technical.. but much bueno.



    couldn't get it to compile though.....



    Deleting intermediate files and output files for project 'cards - Win32 Debug'.
    --------------------Configuration: cards - Win32 Debug--------------------
    Compiling...
    cards.cpp
    fatal error C1083: Cannot open source file: 'C:\Documents and Settings\Owner\Local Settings\Temp\Temporary Directory 1 for cards.zip\cards.cpp': No such file or directory
    Error executing cl.exe.

    cards.exe - 1 error(s), 0 warning(s)
    • "Problem Solving C++, The Object of Programming" -Walter Savitch
    • "Data Structures and Other Objects using C++" -Walter Savitch
    • "Assembly Language for Intel-Based Computers" -Kip Irvine
    • "Programming Windows, 5th edition" -Charles Petzold
    • "Visual C++ MFC Programming by Example" -John E. Swanke
    • "Network Programming Windows" -Jones/Ohlund
    • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
    • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Blackjack Program
    By saber1357 in forum C Programming
    Replies: 1
    Last Post: 03-28-2009, 03:19 PM
  2. Help with Blackjack program
    By sugie in forum C++ Programming
    Replies: 1
    Last Post: 04-30-2005, 12:30 AM
  3. Blackjack!
    By Dr. Bebop in forum Game Programming
    Replies: 1
    Last Post: 10-03-2002, 08:58 PM
  4. Blackjack
    By the_head in forum C Programming
    Replies: 1
    Last Post: 08-03-2002, 08:57 AM
  5. BlackJack Program...
    By 67stangman in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2002, 10:44 PM