Plan out your design first.
Make sure you know how your classes will be designed and how they will interacts with others. Write this out on paper or notepad. Make some pseudo code. This is so much better than 'coding on the fly'. A good design will save u hrs and hrs of fixing mistakes in the future.
Presumably the game will be between 1 human and 1 computer (the dealer). It will be easier to build 1 of them first and make sure it works before adding the other. Usually, it's easier to code a human player since AI is difficult to get right but since the computer's decisions are very basic 'Hit on 16 or less' either choice is fine.
Visual design is important too. What will the user see? How will they interact with what they see? You'll have to think about how you want the cards/score/options/players displayed. In a console it'll just be letters and numbers maybe with a symbol for the suit but K10 (for example) will have to translate to 20 so that comparing values are easier in your code.
After all the basics are working you can think about upgrading (more players, $/score, graphics, sound).
Make sure you know how your classes will be designed and how they will interacts with others. Write this out on paper or notepad. Make some pseudo code. This is so much better than 'coding on the fly'. A good design will save u hrs and hrs of fixing mistakes in the future.
Presumably the game will be between 1 human and 1 computer (the dealer). It will be easier to build 1 of them first and make sure it works before adding the other. Usually, it's easier to code a human player since AI is difficult to get right but since the computer's decisions are very basic 'Hit on 16 or less' either choice is fine.
Visual design is important too. What will the user see? How will they interact with what they see? You'll have to think about how you want the cards/score/options/players displayed. In a console it'll just be letters and numbers maybe with a symbol for the suit but K10 (for example) will have to translate to 20 so that comparing values are easier in your code.
After all the basics are working you can think about upgrading (more players, $/score, graphics, sound).
The following VB.NET project contains the source code and VB.NET examples used for Simple BlackJack Game. Very simple code for a BlackJack game. The source code and files included in this project are listed in the project files section, please make sure whether the listed source code meet your needs there. This Visual Basic Starter Kit is a complete BlackJack card game. The project comes ready to compile and run, and it's easy to customize with only a little extra VB programming. The documentation contains a list of some customizations you might make.
Home > Articles > Programming > Visual Basic
␡- Programming Card Games
Page 1 of 8Next >
In this sample chapter, author Clayton Walnum teaches you how to create a class for manipulating a deck of cards. Learn how to write a class to represent a single card or a deck of cards, and how to use classes to write card programs such as blackjack.
This chapter was selected from Sams Teach Yourself Game Programming with Visual Basic in 21 Days.
Few types of games are more popular than card games. Most households have a deck of cards, and probably more fortunes are won and lost over a card table than on a roulette wheel or a slot machine. That popularity crosses over to computer card games as well. The bottom line is that if you're going to be a Visual Basic game programmer, you need to know how to use VB to handle a deck of virtual cards.
Fortunately, Lady Luck is smiling upon you. In this chapter, not only will you create a class for manipulating a deck of cards, but you'll also get a full set of graphical images for your cards. If there's one thing that discourages most programmers from creating card games, it's the daunting challenge of drawing images for 52 cards—especially the face cards, which are the most graphically complex cards in the deck.
Specifically, today you'll learn the following:
- How to write a class to represent a single card
- How to write a class to represent a deck of cards
- How to write card programs using classes
- How to write a simple blackjack game
Deck-Handling Functions
In the following sections, you'll create a class that you can use to program card games. Before creating a class, however, you have to consider carefully the different ways that you must manipulate the data encapsulated in the class. After you've analyzed your game's needs, you can then write the class's functions. Unfortunately for programmers, there are more card games than craters on the moon. This makes creating a complete card class a nearly impossible task. You can never predict all the different ways that you might need to manipulate cards in your programs.
Java Program Blackjack Code
![Basic Basic](/uploads/1/2/5/1/125174692/864715207.jpg)
Therefore, the best you can do is to write the functions that every card game needs—such as shuffling a deck and dealing hands—and then add more specific functions as you need them. That's the approach this chapter will take with the clsCard class, which will be used in the next few chapters. After you understand how the clsCard class works, you'll be able to add any other functions that you need to create specific card games.
Related Resources
Visual Basic Codes List
There are currently no related titles. Please check back later.