This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

card games, keeping track of the cards.

card games, keeping track of the cards.
by on (#26491)
I have been attempting to write a card game for the nes, and have been having quite the time figuring out a system of keeping the cards in order between two players. i think i have finally found a system that works for this game, though i would like to get some criticism and suggestions if possible. first of, i should state this game is a game of war.

basically, when the game starts out, it generates a deck of cards in random order based off the time it took the player to start the game from the title screen. this deck will then be divided and put in to two stacks of sorts, one for player 1 and one for player 2. and two variables indicating the card counts for both players will be set to 26.

when the players flip out their cards, the first card in the stack will be written to a variable, and the remaining cards still in the stack will be shifted one to the left... the cards will be compared and who ever has the higher card will have both cards added to the right side of the stack (end) and the card counts adjusted accordingly.

if the players both have the same card, and war occurs. both cards will be added to another stack for the waring cards. and a war card count will be created. then four cards will be pulled from each player, the fourth being saved in the current card variables, and all four cards from both players added to the end of the war card array. if players get the same cards this time, war will repeat adding on to the war array. once a player wins, all these cards will be added to the end of the winners stack, card counts will be adjusted.

that is what i am currently thinking is going to work, it is simple and easy to use. before when trying to figure out the best way to manage the cards, i kept making it to complicated and running in to problems, only to create a new problem after fixing each problem before it.

what i would like to see, is suggestions or other ways to keep track of these cards.