A downloadable game

BASIC TENLINER CONTEST 2022

Title: ViperTen64

Language: Basic v2 for Commodore 64

Category: PUR80

Author: Felix Nardella aka "Kimono"


Goal:

====

The goal of this game to control a snake to move and collect food (the numbers from 1 to 9) in the screen map. If you collect all the 9 numbers, you win and the game is over. If you try to move the snake with a movement contrary to its movement (eg move it to the right while it is going to the left), you lose and the game is over.

In the same place where a number is eaten, an obstacle is left. If the snake touch one of the obstacles or the edges of the screen, the game is over. To start the game again just write RUN and press RETURN.


Source (compressed):

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

1?"{white}{147}viperten64 - joy in port2":pO53280,6:a=1064:b=102:c=54272:px=10
2py=13:f=1024:e=49:dx=1:s=5:dIp(30):fOi=atoa 920stE40:pOi,b:pOi 39,b
3w=160:v=c 24:pOi c,2:pOi 39 c,2:nE:x=rN(-ti)
4fOi=atoa 38:pOi,b:pOi 920,b:pOi c,2:pOi 920 c,2:nE
5o=int(rN(0)*919):ifpE(a o)-32gO5
6pOa o,e:ifs>29tH?"{147}"tA252)"congratulations!":eN
7j=pE(56320):ifj-127tHdx=sG(jaN4)-sG(jaN8):dy=sG(jaN1)-sG(jaN2)
8px=px dx:py=py dy:h=f (py*40) px:c=pE(h):ifc=borc=wtH?"{147}you lose!":eN
9fOi=sto1stE-1:p(i)=p(i-1):nE:ifc=etHe=e 1:s=s 3:pOh,w:pOv,15:pOv,0:gO5
10p(0)=h:pOp(0),w:pOp(s),32:gO7
Tip: Copy/paste the program-Code into CBM prg Studio IDE (http://www.ajordison.co.uk/)

Source (uncompressed):

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

1 print"{white}{147}viperten64 - joy in port2":poke53280,6:a=1064:b=102:c=54272:px=10
2 py=13:f=1024:e=49:dx=1:s=5:dimp(30):fori=atoa 920step40:pokei,b:pokei 39,b
3 w=160:v=c 24:pokei c,2:pokei 39 c,2:next:x=rnd(-ti)
4 fori=atoa 38:pokei,b:pokei 920,b:pokei c,2:pokei 920 c,2:next
5 o=int(rnd(0)*919):ifpeek(a o)-32goto5
6 pokea o,e:ifs>29thenprint"{147}"tab(252)"congratulations!":end
7 j=peek(56320):ifj-127thendx=sgn(jand4)-sgn(jand8):dy=sgn(jand1)-sgn(jand2)
8 px=px dx:py=py dy:h=f (py*40) px:c=peek(h):ifc=borc=wthenprint"{147}you lose!":end
9 fori=sto1step-1:p(i)=p(i-1):next:ifc=ethene=e 1:s=s 3:pokeh,w:pokev,15:pokev,0:goto5
10 p(0)=h:pokep(0),w:pokep(s),32:goto7

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

Code comment

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

§ LINE 1:

1 print"{white}{147}viperten64 - joy in port2":poke53280,6:a=1064:b=102:c=54272:px=10

Set the font color to white, clear screen and print the title of the game. Set border color.

'a' base value of the second line of the screen location (1024 40).

'b' value of character poke code.

'c' value of base value of color ram (- screen location).

'px' value of snake's x position.

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

§ LINE 2: 

2 py=13:f=1024:e=49:dx=1:s=5:dimp(30):fori=atoa 920step40:pokei,b:pokei 39,b

'py' value of snake's y position.

'f' base value of the screen location.

'e' character poke code of first number (food).

'dx' value that increases the position of the snake.

's' value of the snake's initial length.

Initializes an array that contains the snake chars.

Draw the the right and left edges.

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

§ LINE 3: 

3 w=160:v=c 24:pokei c,2:pokei 39 c,2:next:x=rnd(-ti)

'w' contains the snake char value.

'v' sound volume.

Colors the left and right edges red.

Initialising random numbers

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

§ LINE 4: 

4 fori=atoa 38:pokei,b:pokei 920,b:pokei c,2:pokei 920 c,2:next

Draw and color the top and bottom edges in red.

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

§ LINE 5:

5 o=int(rnd(0)*919):ifpeek(a o)-32goto5

Generates a random number to determine where to place food (numbers 1 to 9).

Check if the position is free.

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

§ LINE 6:

6 pokea o,e:ifs>29thenprint"{147}"tab(252)"congratulations!":end

Place the food on the screen.

If the length of the snake is greater than 29, you win and the game is over.

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

§ LINE 7:

7 j=peek(56320):ifj-127thendx=sgn(jand4)-sgn(jand8):dy=sgn(jand1)-sgn(jand2)

'j' joystick position value.

Determines the x and y increments from the joy values. The SGN function is used to return 1 if the switch is off or 0 if it is on.

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

§ LINE 8:

8 px=px dx:py=py dy:h=f (py*40) px:c=peek(h):ifc=borc=wthenprint"{147}you lose!":end

Updates the snake's x/y position.

If the snake touches the edges you lose and the game is over.

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

§ LINE 9:

9 fori=sto1step-1:p(i)=p(i-1):next:ifc=ethene=e 1:s=s 3:pokeh,w:pokev,15:pokev,0:goto5

Retraces the entire length of the snake contained in the array. If the snake eats a number, it increases the number to reposition it on the screen and increases the length of the snake. It plays a "tick" (only using SID 6581 version).

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

§ LINE 10:

10 p(0)=h:pokep(0),w:pokep(s),32:goto7

Refresh the snake's head and tail and loop from line 7.

Download

Download
viperten64.prg 532 bytes
Download
viperten64_c.bas 584 bytes
Download
viperten64_u.bas 682 bytes
Download
viperten64.txt 5.7 kB

Install instructions

How to run the game:

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

To run the game I used the C=64 Emulator VICE v3.5(x64.exe).

Then just drag and drop the file "viperten64.prg" on the emulator screen and the game will load and start automatically.

Use joystick in Port 2 to move the snake around the screen.

Tip: it's recommended to perform this operation in order to hear the sound generated by the game: go to SETTINGS (Alt O) -> MACHINE -> MODEL and choose C64 PAL (NOT C64C PAL or other). This will automatically select SID 6581.

Leave a comment

Log in with itch.io to leave a comment.