--- A Windy Day In Africa ---

Written by Sander Alsema for the 10-liner competition 2018.
Language: Commodore 64 Basic v2
Category: PUR-80


I prefer VICE, but you can use any emulator that works with *.d64 files.
If you haven't installed it yet, it can be downloaded from their website.

Here's how to use it:
 Click : File -> Attach disk image -> Drive 8
 Select: A Windy Day In Africa.d64
 Click : Attach

Now, just as you would with a normal Commodore 64, you can type:
 LOAD"$",8             (to load the directory)
 LOAD"AFRICA",8        (to load the game)
 LIST                  (to view the directory or game listing)
 RUN                   (to run the game)

Be aware that you are now using a virtual Commodore 64 keyboard.
Therefore the keys will differ slightly from your physical keyboard.
Use <SHIFT> '2' to display quotation marks.

---

It's a windy day in Africa, and all the leaves are blown from the trees.
You are a hungry giraffe, and you'll have to catch your meal in mid-air
with your mouth. Luckily you have a neck that you can stretch and retract.

Every time you catch a leaf, you move 1 step forward, making it harder to
catch the next one.

If you miss a leaf, you will lose the game.
If you catch 25 leaves, however, you will win!

Here's how to control your neck:
 Stretch, press 'A'
 Retract, press 'Z'

Unlike games that are in an infinite loop, where you just score points
until you die, this game actually has a victory condition.
This means you can win and feel really proud of what you have accomplished!

---

Line 0: Define the string that displays the body and legs of the giraffe.


Line 1: Build the complete neck string of the giraffe (alternating yellow
        and brown) and the horizontal orientation string.

        Read the head string and the victory message string from somewhere
        else in the program to make efficient use of the available space.

        Set the background colour to orange.

        Start with a neck that is 7 characters tall.

        Start with the giraffe at the left side of the screen.


Line 2: Leaves blow from the right side of the screen.

        Calculate a screen memory position, using a randomly chosen
        vertical screen position.

        Clear the screen.

        Display the number of leaves eaten in black.

        Move the cursor to the proper position on the screen.

        Display the body and legs of the giraffe (without carriage return).


Line 3: Move the cursor to the proper position on the screen.

        Display (part of) the neck of the giraffe.

        Display the head of the giraffe.


Line 4: Clear the screen position of the old leaf.

        Move the leaf 1 position to the left.

        Set the colour of the new leaf to green.

        Display the new leaf.

        If the screen position to the left of the leaf contains the mouth
        of the giraffe then move the giraffe 1 step to the right and jump
        back to line 2.


Line 5: Read the keyboard.

        If the pressed key was 'Z' and the neck of the giraffe was not
        fully retracted then retract the neck 1 character.


Line 6: If the pressed key was 'A' and the neck of the giraffe was not
        fully stretched then stretch the neck 1 character.


Line 7: If the leaf has reached the left side of the screen, then change
        the victory message to how many leaves have been eaten, and jump to
        line 9.


Line 8: If the number of leaves eaten is less than 25, then continue the
        game by jumping to line 3.

        This line also holds the data for the head string of the giraffe
        and the victory message string.


Line 9: Clear the screen.

        Display 'GAME OVER' in white.

        Display the victory message (which might be changed).

        Wait a little while.

        Restart the game.

---