A downloadable game

Petefall 10

=======

This is my fourth 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 old demo called "3 adventures" I did back in the 90s.


Plot

----

Not too many people know that Harry Pitfall has a brother, and his name is Pete. Your goal is to help Pete in his adventure as he travels through 32 worlds full of pits. Neither of you like the idea but there is no other way than forward. Help Pete to get out of it. I know you can handle it.

His brother Harry will be proud of you.


Screen

-------

In the top-left corner you can see the current world and the number of lives.


Controls

--------

Use joystick in port 2. Press the fire button to jump.


Code description

----------------

In this game, I wanted to use generated levels (worlds) instead of randomisation. Based on a single value, I achieved some variety for 32 worlds. It's not ideal, but it was really difficult to squeeze it in less than 2 lines of code. I hope that it gives a good sense of variety while playing the game as I wanted to include shorter and longer pits. I also added into design the different length of platforms, so in most cases, the player cannot blindly jump from the beginning to the end but has to jump at the right moment. I also wanted to fit in the animation of the pits, as it just looks way more alive, especially together with the animation of the hero.


Line by line code overview

-------------------------

- Line 0:

- Initialisation of some variables including the main hero animation

- Setting screen and border colours

- Data for X$

- Line 1:

- Increment the current number of the world in case hero has some lives, otherwise reset to the first world

- Reset number of lives to 7 in case it's game over or the first run

- Generate the world based on a value of G variable, counting from 0 to 9 is sufficient to fill the string that represents the current world with at least 40 characters

- Calculate the starting position of world's graphics (A variable) to be taken from W$ and X$ strings

- Data for S$, Y

- Line 2:

- Calculate the length of world's graphics (B variable) to be cut from W$ and X$ strings

- Both strings N$ and $M$ will be created in order to give pits animation effect

- Loops to FOR in line 1 for 10 times

- Clear the screen

- Line 3:

- Read the joystick in port 2

- Set L if the joystick is moved left, R if the joystick is moved right, F if fire button pressed

- Based on joystick values the next horizontal position of hero can be set in X

- Increase hero's animation step only when it moves (C variable)

- Line 4:

- Hero's animation step kept in C variable (from 0 to 2)

- In which direction hero's head should be directed kept in H variable

- Check if hero is requested to jump up that might only occur when he's on the floor (U variable)

- Line 5:

- Calculate hero's jumping up position (P variable) until the max height is reached (Y = 0)

- Calculate hero's falling down position (D variable) until the floor is reached (Y = 3)

- In case the world changed to 33, finish the game by jumping to line 9

- Otherwise, display the actual world number on the top of the screen and continue in line 6

- Line 6:

- Display the actual number of lives

- Display the normal graphics of the world if N = 0

- Display the inverted graphics of the world if N = 1

- Set the vertical and horizontal position where here will be displayed

- Line 7:

- Display hero's head in the right direction based on H variable

- Display hero's upper body part and lower body part based on C variable

- Read the screen memory next to hero's foot and store in A variable in order to detect if hero steps on a pit

- Line 8:

- Decrement one live if hero collides with the pit (when A = 102 or 230)

- Until hero didn't reach the right part of the screen (X is less than 36) and the number of lives is positive, continue the main game loop by jump to line 3

- Otherwise, prepare N$ and M$ to generate the new world and move hero to the left part of the screen followed by jump to line 1 where world generation occurs

- Data for Q$

- Line 9:

- Program jumps here when hero wins the game

- Data for W$, H, S, C$(0...5)


Variables overview

--------------------

- X$ - inverted world graphics, 3 consecutive bytes defines a platform or a pit

- S$ - vertical screen offset

- Y - hero vertical position

- Q$ - moves the printing cursor of the hero character to the next line

- W$ - normal world graphics (see: X$)

- H - hero's head animation position

- S - screen colour address memory

- C$() - table with hero animation containing 3 frames (upper part followed by the bottom part of hero's body)

- G - current world

- V - lives

- I - used for loop iterations

- A - stores the beginning of the world graphics to be cut from X$ and W$ level graphic strings while world generation, also used to detect collision with a pit

- B - stores the length of the world graphics to be cut from X$ and W$ level graphic strings while world generation

- N$ - stores the normal world graphics from W$ string

- M$ - stores the inverted world graphics from X$ string

- J - value of the joystick port 2 address

- L - is the joystick port 2 moved in the left direction

- R - is the joystick port 2 moved in the right direction

- F - is the fire button of joystick port 2 pressed

- K - the next position of hero based on L and R variables

- X - hero horizontal position

- C - hero animation step

- U - is hero requested to jump up

- N - switch world animation (use normal or inverted graphics)

- P - used to calculate if hero is jumping up

- D - is hero falling down

Download

Download
petefall10.d64 170 kB
Download
README.md 5.9 kB
Download
petefall10-listing.txt 1.1 kB

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.