Give him the Hook 10 (C64) by Commocore
A downloadable game
Give Him The Hook
============
This is my third ever 10-liner written in BASIC for Commodore 64.
This game has been submitted to the Basic 10-Liner Contest 2022 in PUR-80 category.
Inspired by the Polish poster from the 70s entitled "Klowni" by Jan Młodożeniec for "The Clowns" movie directed by Federico Fellini.
Plot
----
This is the first game in The Trick Triptych series. A promising clown (although that was what they said about him 20 years ago), got a little bit funky while sipping some suspicious potion from a flask during the circus show. As his performance could at best be described as dull, uncreative and blurpy, people started to yell, and some unidentified flying objects (UFOs) started to fly here and there.
The only thing left to do was to remove the clown from the stage...
Thankfully, you have just the right tool for the job: a Vaudeville hook. Be aware that this is part of the tradition to use the hook if necessary!
As the Art & Tricks & Juggling & Acrobatics & Keep The Animals Happy director of the circus, you know exactly what you should do.
Try to pull away the clown from the stage: "Give him the hook!", the audience is screaming.
He's a stubborn fellow though, so don't be surprised when he tries to get back on stage. And when he does, you'll have to start with this comedy all over again!
Screen
-------
In the top-left corner you can see the current level. As you progress, the distance of the hook increases.
Controls
--------
Use joystick in port 2. To control the position of the hook, move the joystick to the left or right. To release the hook, press the fire button.
Tips & Tricks
--------
Try to aim at the clown's back foot.
Code description
----------------
The great challenge about this 10-liner was that I had no place for IF statements (as in such a case, no further code can be executed after). It made me think
to write all conditions in states, where each state is a combination of mathematical expressions where one part might be excluded or included based on the
multiplication of a condition. It's always interesting to look at things in another way, and this is what I loved about this challenge. For example,
determining the next game level in a single condition was a pretty neat thing to do:
```
V=-(G=-1)*(V*-(G=-1))+1
```
In case G is 0, the level will be reset to 0. In case it's -1, the level will increase by 1.
It's so funny I fell victim to zero-based counting. When I thought that the game was finished, I realised that there were not
10 but 11 lines, starting from 0! So I needed to reduce one full line of BASIC code. Because of that I wasn't able to add any sounds,
something I wished to have initially. Neverthless, I hope that this game is still fun to play!
Line by line code overview
-------------------------
- Line 0:
- Building the hook using a FOR loop, also the string used during the animation when moving the hook up, initialisation of the starting level
- Storing the top part of the clown (in A$) that is stored in DATA (line 9)
- Defining the string used to control hook's vertical position (in U$)
- Setting the screen memory address (in S)
- Line 1:
- Setting up the middle part of the clown (in B$)
- Line 2:
- Setting up the bottom part of the clown in normal state (in C$(0))
- Setting up few variables (described in the variables overview below)
- Line 3:
- Setting up the bottom part of the clown in jump state (in C$(1))
- Setting up few variables (described in the variables overview below)
- Clearing the screen
- Displaying the current level
- Line 4:
- The loop of the game starts here
- Setting up the bottom part of the clown in pulled from the stage state (in C$(2))
- Reading the joystick in port 2
- Setting up the colour of the screen background and border (there was no room left to put it before the game loop)
- Line 5:
- Reading the joystick port 2 address
- Setting the horizontal position of the hook (in L), it also includes the limit and that the hook cannot be moved after releasing it (if M is -1 then the fire button has been pressed)
- For the E variable (vertical position of the hook), if the fire button was pressed this value will decrease so hook will move up until it reaches E = 0
- Line 6:
- In case E = 0, it means that the hook was already released and it reached the top so the horizontal position will be adjusted as well to play the animation of moving the hook to the right
- Displaying the clown in the right position on the screen
- Displaying the hook
- Line 7:
- Randomising the next position of the clown
- Adjust the next position of the clown only if it fulfills a) horizontal position limits (X > 5 and X < 20) b) that no jump is performed (variable U) c) that the hook didn't reach the top (variable E)
- Keeping the state in G variable if the hook caught clown's foot (when X = L)
- Line 8:
- Clearing the next line of the hook in case the animation of moving hook up is performed
- In case G is set, clown will be pulled together with the hook (X will increase)
- U contains the state if the clown jumps (when the hook was close to the clown horizontally (ABS(X-L)<5) and the hook is already on the top (E=0))
- Calculate the state of which bottom part of the clown should be displayed (depends on the U for clown's jump and G for clown's being pulled)
- Line 9:
- In case the hook still didn't reach the top or that the hook horizontal position is in the range, continue the loop by going to line 4
- Otherwise, calculate the next level (if the clown was pulled, level will increase, otherwise it will be resetted to 1), go to line 2 to initialise the level
- At the end, DATA containing the top part of the clown that is read in line 0
Variables overview and some tricks used
---------------------------------------
- P$ - string with the hook
- G$ - string that clears the old hook position
- V - starting level
- A$ - the top part of the clown
- U$ - string used for the vertical position of the hook
- S - screen memory address, used for POKEs
- B$ - the middle part of the clown
- C$(0-2) - graphics for the bottom part of the clown for each state (see: variable A for states description)
- A - animation state for the bottom part of the clown: 0 - normal, 1 - clown jumps, 2 - clown pulled from the stage
- E - vertical position of the hook, also the current level, setting up depending on the result from line 9
- G - keeps the state if clown is pulled from the stage
- L - hook horizontal position
- M - keeps the state if the joystick fire button was pressed
- X - clown horizontal position
- J - reading the joystick port 2 address (56320)
- K - used for determining the next position of the hook, also re-used for randomising the next horizontal position of the clown (-1, 0 or 1)
- U - keeps the state if clown jumps
Status | Released |
Author | BASIC 10Liner |
Genre | Action |
Tags | 8-Bit, basic, basic10liner, Commodore 64 |
Download
Install instructions
Loading
-------
Double click on the d64 image when using emulation. The program should be autoloaded. On the real hardware, just load with:
LOAD"*",8
RUN
The game was tested on real hardware and using WinVice 2.4 emulator.
Leave a comment
Log in with itch.io to leave a comment.