Card games like blackjack, go fish, and poker can be converted to software programs using programming languages like Java or C++. A key step in making a card-game program is getting thoroughly familiar with the original card game. Also, designing a user interface that lets users manage their cards easily is essential, if you're writing a game from scratch. Making a card game lets you design custom "cheats" and other features that make gameplay easier or more interesting.
- Skill level:
Other People Are Reading
Play some existing open-source card games, like Wizard or Yaniv.
Get the source code for a game you want your game to be like. You'll find this code on the same site you got the game's executable.
Open the source files in a word processor and read them, including all comments, which can speak volumes about how a game works.
Make a list of variable names on a piece of paper, and in the second column on the paper write what you think each variable's purpose is, based solely on the variable's name. This list will help you understand the program.
Install a compiler for the programming language that the developers made the original card game with. Read the documentation that came with the source code to determine what this language is. If the language is Java, get a Java development kit from Oracle's site. If the language is C, get a C development kit from the GNU organisation.
Compile the code using the instructions that came with it, and your compiler's instructions.
Step through the code using your development system's debugger. Read the debugger's user guide for detailed instructions on using this tool. Stepping through code is executing a program one statement at a time. By doing this, you can see exactly how the game's variables and data structures change, and how and when essential game logic plays out. In short, you're teaching yourself how the game works.
Write, as you step through the code, comments in the source code files that describe what each statement does. For example, for the statement "while (nAces < 10) keepDrawingCards();" you may write the comment "This statement makes the game continue to draw new cards as long as the number of aces is less than 10." Once you've written a comment for each statement in the game, you'll understand the game well enough to customise it. Continue to the next step when you've reached that point. Until then, continue stepping through the code.
Write the code that produces a change you'd like to see in the game. For example, if you want to customise the deck so that swords appear in place of diamonds, write the code that draws swords on the cards. The knowledge you gained from stepping through the code will let you complete this step.
Continue writing code to implement new changes until the original card game becomes unrecognisable. This event marks the completion of your custom card game.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for