Tuesday, July 14, 2009

C Programming Game Help?

I'm trying to program a game of lives(described below) for a project in college.I'm just having difficulty in understanding how i should go about this. can someone please help.I'm not asking for the code as i would like to do this myself to learn from it.





Lives: Deal 7 cards to each player from a deck, turn the top card of the deck over,you must put a card of the same suit or number down.if you cant you must pick up another card.if you have an ace you can change the suit to whatever you want.





What ever help you can give would be much appreciated!! Thank you

C Programming Game Help?
OK, here some of the things you will need -





Method of displaying a card.


Method of displaying a deck of cards.


Definition of a card, probably a struct with a suit (1 - 4) and a number (1 - 13) .


Array of cards.


Array of players.


Random sorting algorithm (for shuffling the deck).


List of cards in the deck.


List of cards each player has put down.


For loop to go through players.


While loop to go through hands.


Some way of displaying messages (such as 'that card is the wrong suit') might be nice.





Short of writing it for you I don't think I can offer anymore help than that. Good luck.
Reply:The best way to complete a project like this is to make use of design skills, like class diagrams, flow charts, and sequence diagrams. First, translate what you wrote about the game play into objects - what objects will be needed? 'Player' and 'hand' might be a couple. Then, once you have a general idea of the objects you will need to create, make some class diagrams to see how they will relate to each other. After that, do some use case scenarios, and maybe even create some sequence diagrams based on the different scenarios to discover what methods the objects may need. Finally, draft some flow charts for each of the complex, necessary methods. Once you are at this point, it is simply a matter of translating into code, which should be easy at this point.


Many people skip these steps, and end up stuck with a ton of spaghetti code to make their program work. But if you take the time to design it properly, it will pay off in the long run, and save you ALOT of time debugging. Good luck.
Reply:Sounds like uno with regular playing cards...





one word....





ARRAYS


No comments:

Post a Comment