A downloadable game

BASIC TENLINER CONTEST 2021

Title: Obstacle Ski

Language: Basic v2 for Commodore 64

Category: PUR80

Author: Felix "Kimono" Nardella

Goal:

====

The goal of this game is to dodge the obstacles on the ski slope.

Each time you hit an obstacle, the number of falls increases and 

the border color change. 

If you fall more than 5/6 times, the game ends and the time when you

descend and the previous one is indicated. After a few seconds the

game starts all over again.

How to run the game:

===================


Compressed source:

=================

0?"{black}{clear}":r=pE(830):v=53269:pOv+12,1:c=99:t=ti:pO2040,13:fOx=0to33:rEy:pO858+x,y:nE
1j=pE(56320):pOv,1:pOv+18,6:pOv-21,c:pOv-20,60:ifl>10tHl=l-1
2z=sG(jaN4)-sG(jaN8):c=c+z*2:a=11:ifn=20tHifu>3tHa$="{red}####":goS9
3n=int(rN(0)*30)+1:ifn=29tHu=0:a$="{green}A":a=14:goS9
4e=int((ti-t)/120):pO830,e:u=u+1:ifu=30tHl=l+1:u=0:a$="{reverse on}{blue}{arrow left}{dark gray}V{red}Q{reverse off}":a=12:goS9
5f=int(d/2):a$="":a=15:goS9:q=int(rN(0)*3)-1:ifl<-qtHq=0
6l=l+q:s=pE(v+10):ifq=0tHifu>10tHa$="{dark gray}{cm +*2}":a=13:goS9
7ifstHd=d+1:pOv+11,d:iff>5tH?"{reverse on}time:"e*2"s{reverse off} {reverse on}previous:"r*2"s":fOx=0tov/10:nE:rU
8gO1:dA16,,1,57,,,146,,,124,,,186,,,186,,,254,,,124,,,108,,,108,,,108,,,108
9i=int(rN(0)*a)+1:?tAl)"{W*3}"sPi)a$sPa-i)"{black}{W*3}"sP12-l)"f:"f:reT
Tip: Copy/paste the program-Code into CBM prg Studio (http://www.ajordison.co.uk/)

Uncompressed source:

===================

0print"{black}{clear}":r=peek(830):v=53269:pokev+12,1:c=99:t=ti:poke2040,13:forx=0to33:ready:poke858+x,y:next
1j=peek(56320):pokev,1:pokev+18,6:pokev-21,c:pokev-20,60:ifl>10thenl=l-1
2z=sgn(jand4)-sgn(jand8):c=c+z*2:a=11:ifn=20thenifu>3thena$="{red}####":gosub9
3n=int(rnd(0)*30)+1:ifn=29thenu=0:a$="{green}A":a=14:gosub9
4e=int((ti-t)/120):poke830,e:u=u+1:ifu=30thenl=l+1:u=0:a$="{reverse on}{blue}{arrow left}{dark gray}V{red}Q{reverse off}":a=12:gosub9
5f=int(d/2):a$="":a=15:gosub9:q=int(rnd(0)*3)-1:ifl<-qthenq=0
6l=l+q:s=peek(v+10):ifq=0thenifu>10thena$="{dark gray}{cm +*2}":a=13:gosub9
7ifsthend=d+1:pokev+11,d:iff>5thenprint"{reverse on}time:"e*2"s{reverse off} {reverse on}previous:"r*2"s":forx=0tov/10:next:run
8goto1:data16,,1,57,,,146,,,124,,,186,,,186,,,254,,,124,,,108,,,108,,,108,,,108
9i=int(rnd(0)*a)+1:printtab(l)"{W*3}"spc(i)a$spc(a-i)"{black}{W*3}"spc(12-l)"f:"f:return

Tip: Copy/paste the program-Code into CBM prg Studio (http://www.ajordison.co.uk/)

Code comment

============

§ LINE 0:

0print"{black}{clear}":r=peek(830):v=53269:pokev+12,1:c=99:t=ti:poke2040,13:forx=0to33:ready:poke858+x,y:next

Clear screen and set the font color to black.

'r' contains the value of location 830 used to store the time.

'v' contains the value of location to enable sprite.

'c' contains the value of x position of sprite 0.

Colors the background white (1).

Puts the time contained in the system variable 'ti' in the variable 't'.

Load the skier's sprite into memory, starting at location 858.

=========================================================================

§ LINE 1: 

1j=peek(56320):pokev,1:pokev+18,6:pokev-21,c:pokev-20,60:ifl>10thenl=l-1

'j' contains the value of location 56320 (position of the joystick in port 2).

Enable sprite 0.

Set color of sprite 0 to blue.

Set x/y position of sprite 0.

Check that the space of the track width is not more than 10.

=========================================================================

§ LINE 2: 

2z=sgn(jand4)-sgn(jand8):c=c+z*2:a=11:ifn=20thenifu>3thena$="{red}####":gosub9

'z' alternately assumes the values 1 or -1 depending on whether the joystick is in the right or left position.

The x position of the sprite is updated.

'a' contains the max value of spaces to be printed between the borders.

In this case 11 (15-4).

Place a red obstacle in 'a$' if n = 20 and if u > 3.

Go to the subroutine in line 9.

=========================================================================

§ LINE 3: 

3n=int(rnd(0)*30)+1:ifn=29thenu=0:a$="{green}A":a=14:gosub9

'n' contains a random number from 1 to 30.

u = 0 if n = 29

Places a green obstacle in 'a$'.

'a' contains the max value of spaces to be printed between the borders.

In this case 14 (15-1).

Go to the subroutine in line 9.

=========================================================================

§ LINE 4:

4e=int((ti-t)/120):poke830,e:u=u+1:ifu=30thenl=l+1:u=0:a$="{reverse on}{blue}{arrow left}{dark gray}V{red}Q{reverse off}":a=12:gosub9

'e' contains the integer part of the elapsed time.

Uses location 830 (Datasette I/O buffer) to store the elapsed time.

Increases the value of 'u'.

Increases the value of 'l' when the value of 'u' is 30.

Clears the value of 'u'.

Place the obstacle in 'a$' consisting of 3 characters.

'a' contains the max value of spaces to be printed between the borders.

In this case 12 (15-3).

Go to the subroutine in line 9.

=========================================================================

§ LINE 5:

5f=int(d/2):a$="":a=15:gosub9:q=int(rnd(0)*3)-1:ifl<-qthenq=0

'f' contains the collisions' number by the skier

'a' contains the max value of spaces to be printed between the borders.

In this case 15 because there are no obstacles (a$="").

'q' contains a random number between -1 and 1.

Check that the space of the track width is not less than l-1.

=========================================================================

§ LINE 6:

6l=l+q:s=peek(v+10):ifq=0thenifu>10thena$="{dark gray}{cm +*2}":a=13:gosub9

Updates the value of l.

's' contains the value of the collision register between sprites and background.

If the conditions are met (q = 0 and u> 0), add an obstacle.

'a' contains the max value of spaces to be printed between the borders.

In this case 13 (15-2).

Go to the subroutine in line 9.

=========================================================================

§ LINE 7:

7ifsthend=d+1:pokev+11,d:iff>5thenprint"{reverse on}time:"e*2"s{reverse off} {reverse on}previous:"r*2"s":forx=0tov/10:next:run

If a collision is checked:

a) increments d

b) changes background color

c) if the collisions were greater than 5, then stop the game and report the current and previous game times.

d) reruns the game.

=========================================================================

§ LINE 8:

8goto1:data16,,1,57,,,146,,,124,,,186,,,186,,,254,,,124,,,108,,,108,,,108,,,108

Restarts the cycle of the game.

Loads the sprite data.

=========================================================================

§ LINE 9:

9i=int(rnd(0)*a)+1:printtab(l)"{W*3}"spc(i)a$spc(a-i)"{black}{W*3}"spc(12-l)"f:"f:return

'i' contains a random number between 1 and a+1

Writes the contours of the road of random width.

Download

Download
obstacle-ski.d64 170 kB
Download
obstacle-ski.prg 618 bytes
Download
Obstacle_ski.txt 7 kB

Install instructions

To run the game I used the C64 Emulator VICE v3.5.

Here's how to use it:

 Click : File -> Attach disk image -> Drive #8

 Select: obstacle-ski.d64

 Click : Attach

Now, just as you would with a normal Commodore 64, you can type:

 LOAD"$",8                (to load the directory)

 LOAD"OBSTACLE-SKI",8          (to load the game)

 LIST                     (to view the directory or game listing)

 RUN                      (to run the game)

Use Joystick in Port 2 to move the skier to the left or to the right.

Development log

Leave a comment

Log in with itch.io to leave a comment.