A downloadable game

-= PrgTaxi2p                  =-
-=                            =-
-= Written by Doczens         =-
-= 2024 Basic 10Liner Contest =-
-= C64 (EXTREME-256)      

This year I was thinking to bring a game which is connected also to programming, so I figured out a concept to give a path description with some very simple commands and iteration possibility, to traverse through a map. 

To give it some purpose I turned it to a Taxi game. So the map is a city map and the goal is to drive our cab to the passenger to pick him up with a sequence of commands. To implement a program editor and interpreter in the PUR-80 category for pure Basic V2, turned out to be quite a challenge, and I had to cut some of my ideas, both visual and gameplay related, I originally had for the game. But I decided to not let those ideas lost, so I now apply with the advanced version in the EXTREME-256 category. 

The EXTREME-256 version is the full blown 2 player game.

If you start the game you are presented with the program editor tables of Player1 and Player 2 on the left and right and the map at the middle of the screen. On the top of the program editors you can see the earned points of both players so far. The passenger is represented with the heart symbol on the map and both players are to pick up the same passenger. The one reaching earlier wins the round. The map and also the position of the passenger is randomized. Player1's taxi will allways start from the upper left corner of the map, heading to the right while Player2's taxi will allways start from the upper right corner of the map, heading to the left. To control the game Player1 and Player2 uses joystick in port 1 and 2 respectively. 

You start in program editor mode in every new screen. You can use joystick up and down to navigate up and down on the program table. the actual position of the editor is marked with a reversed "E" at the end of the actual row. You can use joystick left to change the command. It will cycle through the available commands:

 - "^": drive one character to the direction of current orientation of the vehicle

 - "<": turn orientation of the vehicle to the left in place

 - ">": turn orientation of the vehicle to the right in place

 - "-": NOP do nothing

With joystick right you can cyle through 1..9 as the number of iterations the given command will be executed. After you are happy with the program you have "written" you can press the fire button to start the interpreter for your own taxi. 

The program execution is now shown on the program editor by the edit mark and also decreasing the iteration count to 0. Meanwhile your Taxi is moving on the map based on the commands executing. The player which is faster, and picks up the passenger earns 50 points and you ae advanced ro the next level. If you leave the road or reach the end of the program before picking up the passenger your turn ends. if none of the players pick up the passenger in a round the game ends and declares the winner.

The game was developed with CBM prg studio and tested on the VICE and HOXs64 emulator.

Though I tried to optimize the code for runtime, the native basic version is quite slow and therefore barely playable, however, this is also attached and can actually run. Fortunatelly a compiled version can run much faster abd much more enjoyable, thanks to the very good optimizations Mospeed can do.


Program code with comments and (number of characters):

!- (201) Initialization
0poke53280,11:poke53281,11:a$="{cm +}{cm +}{cm +}{cm +}PPPP":b$="{down}{left}{left}{left}{left}":c$="{light gray} {red}S":s$="                             ":y=214:x=211:fori=0to3:readc(i),d(i):next:readf(1),f(2),z(1),z(2),cc(1),cc(2),jo(1),jo(2):b=1191:c=55463:
!- (247) Reinit variables for new level, print program editor tables
1fori=1to2:s(i)=0:v(i)=0:e(i)=0:b(i)=z(i):next:o(1)=0:o(2)=2:m=0:?"{clear}{yellow}{down}"ps(1)tab(33)"{cyan}"ps(2):?"{yellow} {cm a}CCC{cm s}"spc(28)"{cyan}{cm a}CCC{cm s}":fori=0to8:p(1,i)=0:p(2,i)=0:q(1,i)=1:q(2,i)=1:?"{yellow} B^ 1B"spc(28)"{cyan}B^ 1B":?"{yellow} {cm q}CCC{cm w}"spc(28)"{cyan}{cm q}CCC{cm w}":next:?"{yellow}{up} {cm z}CCC{cm x}"spc(28)"{cyan}{cm z}CCC{cm x}"
!- (253) Generate map background houses and parks, and randomize passenger placement
2fori=0to3:forj=0to5:pokey,3+i*4:?:pokex,8+j*4:t=abs(int(rnd(0)*3)-1):m$=mid$(a$,1+t*4,4):?chr$(30+122*t)"{reverse on}"m$b$m$b$m$b$m$:next:next:py=int(rnd(0)*6)+1:py=6+(py<2)+(py<4)+(py<7):px=int(rnd(0)*18):px=8-px*(px<3)-(px-10)*(px>16)-int(px/3+2)*(px>2andpx<17)
!- (231) Generate randomized road network
3fori=0to5:rx=(rx+int(rnd(0)*5)-2)*(i>0)*(i<5):ry=(ry+int(rnd(0)*3)-1)*(i>0)*(i<5):forj=0to25:pokey,3-j*(j<16):?"{light gray}":pokex,7+i*5+rx:?"{reverse on} ":next:pokey,3+i*3+ry:?:pokex,7:?"{reverse on}"mid$(s$,1,px-1)mid$(c$,1-2*(py=i),2)"{light gray}"mid$(s$,1,26-px):next
!- (241) Print taxis at initial position, start (forw) main loop, read and process joystick input
4pokey,3:?:pokex,7:?"{reverse on}{yellow}{cm q}",:pokex,32:?"{cyan}{cm w}":forw=0to10000:fori=1to2:poke56322,224:j(i)=notpeek(56319+i):poke56322,255:ee(i)=e(i):on(j(i)=(i*-128)andjo(i)<>(i*-128))+1goto6:u=((jo(i)and1)>0):d=((jo(i)and2)>0):l=((jo(i)and4)>0):r=((jo(i)and8)>0)
!- (172) Edit the taxi programs based on the joystick inputs
5e(i)=e(i)-u*(e(i)>0)+d*(e(i)<8):p(i,e(i))=(p(i,e(i))-l)and3:q(i,e(i))=-((r-q(i,e(i)))*(q(i,e(i))<9)+r*(q(i,e(i))=9))*(r<>0)-q(i,e(i))*(r=0):s(i)=-((jo(i)and16)>0ors(i)<>0)
!- (243) Execute program (interpreter) if the player strated it, move taxis on the road 
6jo(i)=j(i):on-(s(i)<>1)goto8:k(i)=b(i):b(i)=b(i)+(p(i,v(i))=0)*((o(i)=0)+((o(i)=1)-(o(i)=3))*40-(o(i)=2)):o(i)=(o(i)+(p(i,v(i))=1)-(p(i,v(i))=2))and3:e(i)=v(i):t(i)=peek(b+b(i)):pokeb+k(i),160:pokec+k(i),15:pokeb+b(i),d(o(i)):pokec+b(i),cc(i)
!- (197) Check if road is departured, program execution ended or passenger picked up
7:dd(i)=(t(i)<>160)*(p(i,v(i))=0)-(t(i)=211):q(i,v(i))=q(i,v(i))+(q(i,v(i))>0):v(i)=v(i)-(q(i,v(i))=0):s(i)=s(i)+2*((v(i)=9)+(dd(i)>0)):v(i)=v(i)+(v(i)=9):ps(i)=ps(i)-50*(dd(i)=2):m=-(dd(i)=2orm=1)
!- (225) Update the program editor table based on edits/execution
8pokef(i)+ee(i)*80,-66*(ee(i)<>e(i))-(133+abs(s(i))*13)*(ee(i)=e(i)):pokef(i)+e(i)*80,(133+abs(s(i))*13):pokef(i)-3+e(i)*80,c(p(i,e(i))):pokef(i)-1+e(i)*80,48+q(i,e(i)):next:w=-(((s(1)<0ands(2)<0))+(m>0))*10000::next:onmgoto1
!- (252) Print game over message, data c(i),d(i),f(i),z(i),cc(i),jo(i)
9wi=-(ps(1)>ps(2))-2*(ps(1)<ps(2))-3*(ps(1)=ps(2)):pokey,1:?:pokex,15:?"{white}game over"spc(29)mid$("{yellow}{cyan}{white}",wi,1)"player"mid$("12s",wi,1)"{white} "mid$("wins!wins!draw!",1+(wi-1)*5,5):pokey,20:?:poke198,0:data30,235,60,242,62,243,67,241,1149,1182,0,25,7,3,-128,-256

!- Variable            Comment

!-------------------------------------------------

!- d                   flag for joystick down

!- i                   general cycle variable

!- j                   general cycle variable

!- l                   flag for joystick left

!- m                   flag if a player succesfully picked up the passenger

!- m$                  randomized scenery pattern house/park

!- px                  randomized position of passenger x

!- py                  randomized position of passenger y

!- r                   flag for joystick right

!- rx                  randomized offset of vertical roads

!- ry                  randomized offset of horizontal roads

!- t                   temporary variable

!- u                   flag for joystick up

!- w                   main loop cycle variable

!- Array               Comment

!- ------------------------------------------------

!- b(1..2)             actual screen address ofset of the taxis relative to b

!- e(1..2)             program editor position

!- j(1..2)             joystick state

!- k(1..2)             taxi memory address offset from previous cycle

!- o(1..2)             orientation of the taxis

!-                      0-east, 1-south, 2-west, 3-north

!- p(1..2, 0..8)       program commands, 

!-                      0=forward, 1=turn left, 2=turn right, 3=NOP

!- q(1..2, 0..8)       program repeat counts

!- s(1..2)             flag to program execution start

!- v(1..2)             program counter position

!- dd(1..2)            enum to show check results

!-                      0-none, 1-road departure, 2-passenger pick up

!- ee(1..2)            edit/execute marker position from previous cycle

!- jo(1..2)            joystick state from previous cycle    

!- ps(1..2)            earned points of the players

!- Constant            Comment

!- ------------------------------------------------

!- a$                  house and park scenery characters

!- b                   screen memory address of upper left map corner 

!- b$                  move 1 line down for scenery drawing

!- c                   color memory address of upper left map corner 

!- c$                  road (space) and passenger (hart) symbols for 

!- s$                  28 space to draw horizontal roads

!- x                   memory address for cursor column positioning 

!- y                   memory address for cursor column positioning 

!- Constant array      Comment

!- ------------------------------------------------

!- c(0..3)             screen code of program command symbols

!-                       30 (^),60(<),62(>),67(-)

!- d(0..3)             screen code of taxi based on orientation

!-                       235(right),242(down),243(left),241(up)

!- f(1..2)             screen memory address of programing tables

!- z(1..2)             address offset of taxi start position relative to b

!- cc(1..2)            player colors: yellow, cyan 

Download

Download
prgtaxi2p.bas 6.1 kB
Download
prgtaxi2p.d64 170 kB
Download
prgtaxi2p.txt 9.8 kB

Install instructions

The game is delivered on a D64 disk image.

In VICE first attach the disk image from the menu:

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

 - Load the compiled version with LOAD”PRGTAXI2P”,8,1 and RUN.

The native basic version is also available, 

 - Load the compiled version with LOAD”PRGTAXI2PSLOW”,8 and RUN.

Leave a comment

Log in with itch.io to leave a comment.