One of the more simple games to program would seem to be a card game
but if you are just starting to learn Atari Basic the task may not be as
simple as it seems. In this article I present you with a pack of cards
for you to turn into whatever game takes your fancy.
Graphics 1 would seem to be the ideal choice for a card game using
the control characters representing the card suits but unfortunately
there is not enough room on the screen to feature sufficient cards. This
program uses Graphics 0 and so looses the option of colour for the
'pips' but does allow up to ten cards on the screen.
Let's go through the listings. The first listing creates the pack of
cards and in LINES 50 - 75 goes through the entire pack to allow you to
check that everything is alright. You can add Listing 2 later as an
example of how to deal the cards.
LINE 10 -
Dimensions strings. A$ holds the entire pack whilst the CARD strings
hold individual cards to be picked by random routines in listing 2.
LINES 20 -
25 fill the strings with the same characters. In the case of A$ the
'pips' are poked in later.
opens the Keyboard for direct input later in the game.
LINES 30 -
35 set some colour and put a title up while the program creates the
cards in the routine beginning with LINE 400.
- 490 are the 'card-making' routine.
goes through the 52 cards and first reads the CARDNO from the DATA which
is the number of 'pips' on each card.
- 414 change the characters from hearts to clubs to diamonds to spades.
Refer to Appendix C of the Basic Manual.
reads the position of each 1 pip and places the appropriate character in
the correct place in the string.
Restores the DATA for each of the four suits.
- 480 step through the 11th, 12th and 13th cards of each suit to add the
letters representing the court cards.
program then goes back to line 50 to run through the pack.
your pack of cards. Now add listing 2 to see how these can be dealt out.
The program picks 4 random numbers to represent four cards and makes
sure that you don't have two cards the same. Each card is made up of 63
characters and these are picked out of A$ at the appropriate point and
put into the CARD strings. These are then printed out line by line at
set positions on the screen to give you your 'deal'.
do now is up to you -blackjack, poker, snap (!) or whatever. Add
scoring, a money pot, anything you wish. If you can make up a good game
send it in for a future article.