could i see your code after you finish your game..?? :D
Printable View
could i see your code after you finish your game..?? :D
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.
that's pretty much 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
}
NOTE: it wasn't copied directly.
you have a chicken in your pants....?!??? :confused:
Yep! :D
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.
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. ChangeQuote:
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.
toCode: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.Code:void swap(CARD &x, CARD &y);
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).
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...? :D
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)
i don't think women can even teach women :confused:
true dat.Quote:
Originally Posted by The Brain
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;
}
will const char suit[4] = {3, 4, 5, 6}; work without using ' ' char notation
ex:
const char suit[4] = {'3', '4', '5', '6'};
>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. ;)
outstanding. :cool:
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 :D The petter-color.h file is used for the colors so be sure to include it.
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)