card game

How do you create a game where two players each draw a card, where the card deck is created by an array?
With code.

-Albatross



Sorry, but that's a question so broad, there's no meaningful answer anyone could give. After the cards are drawn, then what? What if there's a tie? How many rounds are played? Is the game local multiplayer, or over a network? Does there need to be a game server? Is it a console game, or are there proper graphics? Or are you asking specifically about how to make a virtual deck of cards using an array?

EDIT: This post is an exact duplicate of http://www.cplusplus.com/forum/beginner/258234/
Please do not multi-post. Also, people gave you plenty of good answers in that thread. What was wrong with them?
Last edited on
You could start by creating a card structure or class. I suppose it first begins with what kind of cards you are going to use. That is, is it a standard deck of cards or a universal deck that can be anything - e.g. a tarot deck, go fish, magic the card game, and so on... You probably need to define the game parameters first and then work the logic down to start with some sort of data structures.

Once you have that you might use a loop to populate the 'array' with the cards to build the master deck. Possibly have two more arrays - one for each player. You draw [delete or mark used] a card from the master deck, and place (copy) into the player's hands (their respective arrays); thereby dealing out the first hand or round of the 'game.'

Game play will be based on the rules of what the game is of course. Better start with some basic layout.
Topic archived. No new replies allowed.