C Board  

Go Back   C Board > General Programming Boards > Game Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 06-08-2003, 02:22 PM   #1
plzduntlakliekthiskthx
 
Join Date: Oct 2002
Posts: 138
My blackjack game is done!

The exe and source code are in the zip... Please play the game before looking at the code too much, because im sure the code will change your opinion of the game . Tell me what ya think!
Attached Files
File Type: zip blackjack.zip (175.5 KB, 90 views)
o0obruceleeo0o is offline   Reply With Quote
Old 06-08-2003, 05:10 PM   #2
plzduntlakliekthiskthx
 
Join Date: Oct 2002
Posts: 138
oh yeah! remember to maximize the console window and scroll all the way when you play
o0obruceleeo0o is offline   Reply With Quote
Old 06-08-2003, 06:26 PM   #3
Pursuing knowledge
 
confuted's Avatar
 
Join Date: Jun 2002
Posts: 1,916
I'm impressed.
__________________
Away.
confuted is offline   Reply With Quote
Old 06-08-2003, 06:31 PM   #4
Pursuing knowledge
 
confuted's Avatar
 
Join Date: Jun 2002
Posts: 1,916
you should clear "BLACKJACK!" off the screen after a new hand is dealt. I'm still impressed.

edit: actually, there are a couple errors there. Check 'em out.
__________________
Away.

Last edited by confuted; 06-08-2003 at 06:33 PM.
confuted is offline   Reply With Quote
Old 06-08-2003, 07:10 PM   #5
plzduntlakliekthiskthx
 
Join Date: Oct 2002
Posts: 138
the only error I know of is that every once in a while it will take a while to deal out a card because it keeps trying to deal a card that is already there and the rand card keep getting already delt cards (ie there arent 2 ace of spades in a deck of cards )
o0obruceleeo0o is offline   Reply With Quote
Old 06-09-2003, 10:00 AM   #6
Crazy Fool
 
Perspective's Avatar
 
Join Date: Jan 2003
Location: Canada
Posts: 2,596
Quote:
Originally posted by o0obruceleeo0o
the only error I know of is that every once in a while it will take a while to deal out a card because it keeps trying to deal a card that is already there and the rand card keep getting already delt cards (ie there arent 2 ace of spades in a deck of cards )
to solve this, why not keep an array of every possible card then randomly chose an index in that array ( between 0 and SIZE where SIZE is the size of the array, initially 52) then after you chose a card, copy the card in the last position (SIZE - 1) to the index of the card you just selected and decrease the size of the array by one!
Perspective is offline   Reply With Quote
Old 06-09-2003, 10:38 AM   #7
Cheesy Poofs!
 
PJYelton's Avatar
 
Join Date: Sep 2002
Location: Boulder
Posts: 1,728
I like the graphics, good job!

My only problem with it is that its played in a two player style instead of a casino style (player vs dealer) which is how it is usually played. It would be kind of cool if you allowed betting, doubling down, splitting etc.

I looked at the code and I must say that there is a LOT of redundant code. Instead of having huge if statements for every card position drawn, couldn't you have it once? Since the only thing that changes is the x and y position drawn, all you would need to do is pass those variables to the function, something like this:
Code:
void drawCard(int xPos, int yPos)
{
    //draw card at xPos and yPos;
}

int main()
{
     // get first card
     drawCard(0,0);
     // get second card
     drawCard(50,0);
     // etc etc
}
So you would only need a separate function that draws the upside down card, all other cards could be drawn using the x and y positions and the drawCard function.

Also, a real easy way to keep track of a deck of cards (and you don't want to use structs or objects) is to simply have an array of ints of size 52. To start off, deck[0]=0, deck[1]=1, deck[2]=2 etc. Then you have a function that shuffles the deck randomly like this:
Code:
for (int x=0; x<52; x++)
   swap deck[x] with deck[rand()%52];
Then just pull cards off the top of the deck, modulus 13 and modulus 4 to find out the card value and suit. Never have to worry about duplicate cards and you could just reshuffle as often as you like and start over with the first card.
PJYelton is offline   Reply With Quote
Old 06-09-2003, 07:28 PM   #8
plzduntlakliekthiskthx
 
Join Date: Oct 2002
Posts: 138
To be honest, after I realized the problems in my code I did not change it because I got lazy and bored of making the program lol. Right now I am in the part if my book where I start to learn some windows programming, so Im excited to make a game in windows...
o0obruceleeo0o is offline   Reply With Quote
Old 06-10-2003, 01:27 PM   #9
Pursuing knowledge
 
confuted's Avatar
 
Join Date: Jun 2002
Posts: 1,916
After the blackjack, it doesn't clear the text for the blackjack off the screen, and it doesn't show the new cards when you deal until the hand after the hand immediately after the blackjack.
__________________
Away.
confuted is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Blackjack Program saber1357 C Programming 1 03-28-2009 03:19 PM
2D Game project requires extra C++ programmers, new or experienced drallstars Projects and Job Recruitment 2 05-16-2007 10:46 AM
PC Game project requires c++ programmers drallstars Projects and Job Recruitment 2 02-22-2006 12:23 AM
Game Engine Link Prob swgh Game Programming 2 01-26-2006 12:14 AM
Game Programmer's AIM Circle: Join Today KingZoolerius66 A Brief History of Cprogramming.com 28 12-20-2003 12:12 PM


All times are GMT -6. The time now is 12:39 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22