====================================
  T h e  S p i r a l
====================================
   Title: The Spiral
Platform: Commodore 16, Plus/4
  Author: Giuseppe Mignogna
Language: BASIC 3.5
Category: PUR-80
====================================

Intro
-------------------
This game has been written using CBM prg Studio 3.13.
It has been tested with the emulators Yape 1.1.7 and Plus4emu 1.2.9.2. Vice should be OK too, but I didn't try it.


How to run
-------------------
To run it, simply drag and drop the .d64 file into Yape -OR- attach it to drive 8, type DLOAD"*" and then type RUN. 

NOTICE: since this program traps the Run/Stop, you will not be able to stop it while running. If you want to list the code, you can manually attach the disk image, type DLOAD"THESPIRAL" and then type LIST. Also, you can do a soft reset to the m/l monitor (TAB + F11) and then type X to exit it. 


How to play
-------------------
To play, use the joystick in port 2. The goal of the game is to pilot a space ship through a deadly spiral. You have to exit the spiral and touch the portal (that's, the Big Box), in the shortest time possible. Use left and right to rotate the ship, fire to accelerate. There are ten different levels, you can play againest yourself trying to beat your best time. The time is in 60ths of second and it is reset each time the ship hits the spiral. If you get bored of a level, you can chose another one by pressing Run/Stop at any time.   


Code
-------------------
1) Shortened code (80 characters max per line):

0tR0:vO8:gR0,1:h=5e4:input"the spiral -joy2,rstop- level 1-10";l:ifl<1orl>10tH0
1colO0,1:colO1,6+l:gR1,1:fOy=1to1.2stE.1:a=6:loC96,184:fOr=100to5stE-2+l/10
2dRtosI(a)*r*y+160,cos(a)*r*y+100:a=a+0.3:nE:nE:bO,30,100,60,199,,1:pA1,140,198
3x=155:y=99:vx=0:vy=0:a=180:fOr=600to960stE15:sO1,r,1:nE:j=0:t=ti
4ifj>127tHr=a/57.3:vx=vx+sI(r)/1.4:vy=vy-cos(r)/1.4:j=j-128:sO3,0,0:sO3,550,15
5cI0,x,y,2,4,,,a,120:ifj=3tHa=a+18:eLifj=7tHa=a-18:ifa<0tHa=360
6loCx+4*sG(vx),y+4*sG(vy):ifrD(2)=0tH7:eLifx<74tH8:eLgO3
7x=x+vx:y=y+vy:cI1,x,y,2,4,,,a,120:j=jO(2):gO4
8s=ti-t:h=(s-h)*(h<s)+s:chA1,0,0,"time:"+stR(s)+" best:"+stR(h)+"        "
9fOx=100to700stE100:fOr=xtox+250stE25:sO1,r,1:nE:nE:gO3


2) Plain code:

0 trap0:vol8:graphic0,1:h=5e4:input"the spiral -joy2,rstop- level 1-10";l:ifl<1orl>10then0
1 color0,1:color1,6+l:graphic1,1:fory=1to1.2step.1:a=6:locate96,184:forr=100to5step-2+l/10
2 drawtosin(a)*r*y+160,cos(a)*r*y+100:a=a+0.3:next:next:box,30,100,60,199,,1:paint1,140,198
3 x=155:y=99:vx=0:vy=0:a=180:forr=600to960step15:sound1,r,1:next:j=0:t=ti
4 ifj>127thenr=a/57.3:vx=vx+sin(r)/1.4:vy=vy-cos(r)/1.4:j=j-128:sound3,0,0:sound3,550,15
5 circle0,x,y,2,4,,,a,120:ifj=3thena=a+18:elseifj=7thena=a-18:ifa<0thena=360
6 locatex+4*sgn(vx),y+4*sgn(vy):ifrdot(2)=0then7:elseifx<74then8:elsegoto3
7 x=x+vx:y=y+vy:circle1,x,y,2,4,,,a,120:j=joy(2):goto4
8 s=ti-t:h=(s-h)*(h<s)+s:char1,0,0,"time:"+str$(s)+" best:"+str$(h)+"        "
9 forx=100to700step100:forr=xtox+250step25:sound1,r,1:next:next:goto3


3) Code explanation

Line 0: level selection;
Lines 1,2: some graphics initialization; spiral and big box drawing;
Line 3: some variables are initialized, like ship parameters and time counter;
Line 4: handles ship acceleration;
Line 5: deletes the ship; controls the ship rotation;
Line 6: collision detect;
Line 7: new ship's position is calculated; the ship is drawn;
Line 8: shows the time spent and update the best (lowest) time;
Line 9: plays a sound effect and restart from 3.

-end-