10 MEMORY 21999
15 CALL &BC02
20 DEFINT a-z
25 CALL &6B78
30 |MUSICOFF
35 TOTALTIME=60
40 ENV 1,11,-1,50:'explosion
45 DIM pts(11): DIM name$(11):'scores
50 DIM s(30):FOR i=0 TO 30:s(i)=1000-i*15:NEXT:'car sounds
55 MODE 0:b=0
60 FOR j=0 TO 31:|SETUPSP,j,0,&X0:NEXT
65 |3D,1,30,0
70 GOSUB 705:INK 0,0: INK 1,13
75 GOSUB 175
80 |SETLIMITS,0,80,0,200
85  k=13:t=0:INK 0,t: INK 1,(t+k) MOD 27
90 |MUSIC,0,6
95 |MAP2SP, &X1000011:'status de map2sp para intro
100 y=0: x=4:score=0
105 clist=&565E: c0=0:c0end=0:c1=0:c1end=0:c2=0:c2end=0
110 |PEEK,clist,@c0:|PEEK,(clist+2),@c0end
115 c1=c0end:|PEEK,(clist+4),@c1end
120 c2=c1end:|PEEK,(clist+6),@c2end
125 |UMAP,c0,c0end,0,1000,0,600:' update MAP
130 |PRINTSPALL,0,0,0:' ciclo de demo
135 |MAP2SP,y,x
140 |PRINTSPALL
145 y=y+4: c=c+1
150 IF c =100 THEN C=0:t=(t+1) MOD 27:INK 0,t: INK 1,(t+k) MOD 27
155 IF y>=600 THEN y=300: k=11+ (k+1) MOD 5: b=1+b MOD 100
160 IF INKEY(47)=0 THEN 1195
165 IF b>50 GOTO 1195:'score table
170 GOTO 135
175 '--- ESCENARIO INTRO ---
180 WINDOW 1,20,12,25:PAPER 0:CLS
185 PLOT 0,200,1:DRAW 640,200
190 PLOT 0,192,1:DRAW 640,192
195 PLOT 0,175:DRAW 640,175
200 PLOT 0,150:DRAW 640,150
205 PLOT 0,100:DRAW 640,100
210 PLOT 0,25:DRAW 640,25
215 FOR i=-300 TO 300 STEP 25:PLOT 320-i,200:DRAW 320-i*4,0:NEXT
220 WINDOW 1,20,1,12:PAPER 2:CLS:'cielo negro
225 CALL &BBE4,1,1:' igual que "GRAPHICS PAPER 2" pero vale en cpc464
230 TAG:PLOT -1,-1,12: MOVE 4*32-4,24*16-2:PRINT "3D RACING ONE";:TAGOFF
235 PAPER 2:PEN 5:LOCATE 5,2: PRINT CHR$(22)+CHR$(1);"3D RACING ONE";CHR$(22)+CHR$(0);
240 PAPER 2:PEN 5:LOCATE 1,11:FOR i=1 TO 40:PRINT CHR$(&86);:NEXT
245 PLOT 0,204,6:DRAW 640,204:PLOT 0,204+36,6:DRAW 640,204+36:'lineas rojas
250 INK 8,0:c$="BY JOSE JAVIER GARCIA ARANDA   2018": |PRINTAT,0,4*8,3*2,@c$
255 c$="A FULLY BASIC PROGRAM CREATED WITH 8BP": |PRINTAT,0,6*8,2,@c$
260 RETURN
265 'orden de ejecucion fases
270 GOSUB 340:' fase 1, skills
275 GOSUB 795:'fase 2, competition
280 GOSUB 1725:'fase 3, superfast
285 GOSUB 1910:'fase 4 noche
290 GOTO 2120:'get name y fin
295 RUN
300 '--- TITULO FASE ---
305 GOSUB 705:INK 8,0:INK 0,0:INK 13,15:INK 4,6:MODE 0:CLS
310 |PRINTAT,0,50,24,@cad$
315 |3D,0:|SETUPSP,0,0,1:|SETUPSP,0,9,70:|PRINTSP,0,60,34:|3D,1,22,offsety
320  cad$="PRESS SPACE":|PRINTAT,0,90,30,@cad$
325  IF INKEY(47)=0 THEN RETURN
330 GOTO 325
335 '--- FASE 1 ---
340 cad$="LEVEL 1 : GET SKILLS":GOSUB 300
345 GOSUB 915
350 c=c1:cend=c1end
355 GOTO 420
360 '--- RUTINA SCORE ---
365 MODE 0:|MUSICOFF:GOSUB 705:INK 8,0:INK 0,0:INK 13,15:INK 4,6
370 cad$= "CURRENT SCORE:"+STR$(SCORE):|PRINTAT,0,30,24,@cad$
375 cad$="DISTANCE  X  DAMAGE": distance= distance +y:|PRINTAT,0,50,20,@cad$
380 PAPER 2:PEN 5:LOCATE 1,18:FOR i=1 TO 40:PRINT CHR$(&86);:NEXT
385 FOR i=0  TO int(distance/50)
390 cad$=STR$(i)+" X "+STR$(21-damage)+" : "+STR$(i*(21-damage))
395 |PRINTAT,0,60,22,@cad$:SOUND 7,200,2,7,1,1
400 NEXT
405 score=score +(INT(distance/50))*(21-damage):cad$= "NEW SCORE:"+STR$(SCORE):|PRINTAT,0,80,24,@cad$
410 IF INKEY(47) THEN 410
415 RETURN
420 |UMAP,c, cend,y,y+550,0,600
'425 POKE &B8B4,0:POKE &B8B5,0:POKE &B8B6,0:POKE &B8B7,0:A=TIME
430 |PRINTSPALL,0,0,0: distance=0
435 |AUTOALL,1
440 ' --- CICLO JUEGO FASE 1---
445 y=y+vy:x=x+dx:col=PEEK (coli)+PEEK(cold):IF col THEN IF vy>1 THEN damage=damage+1:INK 8,3:GOTO 455 ELSE col=0
450 IF INKEY(67) THEN 455 ELSE |MOVER,22,flag,0:flag=-flag:IF vy<14 THEN vy=vy+1:|MOVER,26,0,1:GOTO 460 ELSE 460
455 IF vy THEN vy=vy-1:|MOVER,26,0,-1
460 IF INKEY(34) THEN 465 ELSE img=carl:|MOVERALL,0,1:IF dx>-7 THEN dx=dx-1:IF dx>0 THEN SOUND 4,50,16,7,0,1:GOTO 480 ELSE 480 ELSE 480
465 IF INKEY(27) THEN 470 ELSE img=carr:|MOVERALL,0,-1:IF dx<7 THEN dx=dx+1:IF dx<0 THEN SOUND 4,50,16,7,0,1:GOTO 480 ELSE 480 ELSE 480
470 IF dx THEN 480 
475 img=car
480 IF imgant-img THEN |SETUPSP,22,9,img:imgant=img
485 SOUND 1,s(vy),16,7:|MAP2SP,y,x:|PRINTSPALL
490 t1=1+t1 AND 15:IF t1 THEN 505
495 t=t-1:IF t>9 THEN t$=STR$(t) ELSE t$=STR$(t)+" "
500 |PRINTAT,0,190,70,@t$: IF t THEN 520 ELSE 535
505 IF t1-8 THEN 515
510 |UMAP,c,cend,y,y+425,0,1000:GOTO 520
515 IF y>2900 THEN y=y-2900:|UMAP,c,cend,y,y+450,0,1000:distance=distance+2900 ELSE |AUTOALL
520 IF col THEN INK 8,5:SOUND 2,3000,10,7,0,0,1:IF damage<20 THEN |MOVER,27,0,1:col=0 ELSE 535
525 GOTO 445
535 '--- MUERTE o END LEVEL ---
'540 FPS=10*(TOTALTIME-t)*16*300/(TIME-A):' locate 1,1:print FPS: input a
'545 |3D,0  
540 |3D,0
550 IF t>0 THEN 610: 'muerte
555 'final circuit
560 WINDOW 1,20,1,21:PAPER 2:CLS:WINDOW 1,20,2,11:PAPER 8:CLS
565 PAPER 8:PEN 5:LOCATE 1,1:FOR i=1 TO 40:PRINT CHR$(&86);:NEXT
570 cad$="CONGRATULATIONS !!":|PRINTAT,0,40,24,@cad$
575 PAPER 8:PEN 5:LOCATE 1,9:FOR i=1 TO 40:PRINT CHR$(&86);:NEXT:|MUSIC,1,6 
580 cad$=" CONGRATULATIONS!. YOU HAVE PASSED THIS RACING CIRCUIT ": k=0
585 FOR i=80 TO -120 STEP -1:|PRINTAT,0,60,i,@cad$: k=k+1
590 IF INKEY(47)=0 OR k=500 THEN 360 
595 NEXT
600 GOTO 585
605 '--- MUERTE ---
610 FOR j=0 TO 31:|SETUPSP,j,0,0:NEXT:'reset
615 FOR i=0 TO 4
620 |SETUPSP,i,0,128+8+1+64:|SETUPSP,i,9,22:|SETUPSP,i,15,4-i
625 |LOCATESP,i,148,39+i*3:
630 NEXT i
635 |SETUPSP,11,9,explo:|SETUPSP,11,0,64+1+4: |LOCATESP,11,141,40
640 |SETUPSP,11,7,1
645 FOR i=1 TO 2:|AUTOALL,1:NEXT
650 FOR i=5 TO 9
655 |SETUPSP,i,0,128+8+1+64:|SETUPSP,i,9,24:|SETUPSP,i,15,4-(i-5)
660 |LOCATESP,i,148,41+(i-4)*2:
665 NEXT i
670 incy=0
675 SOUND 3,0,600,15,1,,15
680 |AUTOALL,1:|PRINTSPALL,0,1,0:
685 FOR i=1 TO 200:NEXT i
690 IF INKEY(47)=0 THEN GOSUB 360: GOTO 2120
695 GOTO 680
705 '--- BEGIN PALETA ---
710 INK  0 , 13 :'gris
715 INK  1 , 9:'verde oscuro 
720 INK  2 , 0 :'negro
725 INK  3 , 0 
730 INK  4 , 26 :'blanco
735 INK  5 , 26 
740 INK  6 , 6 :'rojo
745 INK  7 , 6 
750 INK  8 , 5 :'morado
755 INK   9 , 19:'verde claro 
760 INK  10 , 24 :'amarillo
765 INK  11 , 24 
770 INK  12 , 11 :'azul oscuro
775 INK  13 , 20 :'azul claro
780 INK  14 , 15:'naranja
785 INK  15 , 15 
790 RETURN
795 '---FASE 2 ---
800 |MUSICOFF: cad$="LEVEL 2 : COMPETITION": GOSUB 300
805 RESTORE 1540:GOSUB 1350:'crea level 2
810 MODE 0: GOSUB 915: 'escenario
815 INK 1, 12: INK 15,24:'cesped y suelo montanas
820 FOR i=28 TO 31:|SETUPSP,i,0,0:NEXT:|SETUPSP,28,9,montanabig:posm=0
825 |PRINTSP,28,83-offsety,10: |PRINTSP,28,83-offsety,40:|PRINTSP,28,83-offsety,60
830 FOR i=18 TO 21
835 |SETUPSP,i,0,128+64+16+8+1
840 |SETUPSP,i,9,66
845 |SETUPSP,i,5,0,0
850 |SETUPSP,i,15,8
855 |LOCATESP,i,200,140
860 dir(21-i)=27000+i*16+1
865 NEXT
870 ey=0:'coordY de un enemigo cualquiera
875 c=c2:cend=c2end:distance=0
880 FOR i=23 TO 25:|SETUPSP,i,0,0:NEXT:'quito nubes
885 y=0
890 FOR i=1 TO 10:|ROUTESP,18:|AUTO,18:NEXT
895 FOR i=1 TO 100:|ROUTESP,19:|AUTO,19:NEXT
900 FOR i=1 TO 200:|ROUTESP,20:|AUTO,20:NEXT
905 FOR i=1 TO 300:|ROUTESP,21:|AUTO,21:NEXT
910 GOTO 1555
915 '--- VARIABLES Y MARCADORES JUEGO ---
920 |MUSICOFF:FOR i=0 TO 15:INK i,0:NEXT
925 |MAP2SP, 3:'status map2sp
930 |SETLIMITS,0,80,0,200
935 FOR j=0 TO 31:|SETUPSP,j,0,&X0:NEXT
940 |SETUPSP,22,0,33+64
945 car=17:carl=18:carr=19
950 flag=1
955 casas=16: nube=20: fragment=22
960 montanas=27:montanabig=69
965 explo=23
970 cartelzoom=64: campozoom=65
975 |SETUPSP,22,9,car
980 posy=164: posx=160
985 |LOCATESP,22,posy,posx:'mi coche
990 offsety=32
995 coli=&C000+INT((posy-4 -offsety)/8)*80 +((posy-4 -offsety) MOD 8)*2048 +40+2
1000 cold=coli+8
1005 ENT 1,5,2,1,5,-2,1,5,2,1,5,-2,1:'derrape
1010 'casas con flag moverall
1015 |SETUPSP,29,0,1+16:|SETUPSP,29,9,casas:|LOCATESP,29,83-offsety,10
1020 |SETUPSP,30,0,1+16:|SETUPSP,30,9,casas:|LOCATESP,30,83-offsety,30
1025 |SETUPSP,28,0,1+16:|SETUPSP,28,9,casas:|LOCATESP,28,83-offsety,40
1030 |3D,0  
1035 GOSUB 1080: 'pinta escena y marcadores
1040 |3D,1,22,offsety
1045 y=0:x=0: damage=0
1050 x=210
1055 vy=0:dx=0
1060 t=TOTALTIME:t1=10
1065 img=car:imgant=car  
1070 GOSUB 705:'paleta
1075 RETURN
1080 '--- PINTA ESCENA Y MARCADORES---
1085 WINDOW 1,20,22,25:PAPER 8:CLS:'marcadores
1090 WINDOW 1,20,1,9:PAPER 12:CLS:'cielo
1095 PLOT 0,200+offsety*2,2:DRAW 640,200+offsety*2:'horizonte negro 
1100 FOR y=offsety*2 TO 198+offsety*2 STEP 2:PLOT 0,y,1:DRAW 210-(200-y),y:DRAW 460+(200-y),y,0:DRAW 640,y,1:NEXT     
1105 |SETUPSP,25,9,nube:|SETUPSP,25,0,137:|LOCATESP,25,40,10:'nubes
1110 |SETUPSP,24,9,nube:|SETUPSP,24,0,137:|LOCATESP,24,40,30
1115 |SETUPSP,23,9,nube:|SETUPSP,23,0,137:|LOCATESP,23,40,60
1120 |SETUPSP,25,15,5:|SETUPSP,24,15,6:|SETUPSP,23,15,7:
1125 FOR y=202+offsety*2 TO 220+offsety*2 STEP 2:PLOT 0,y,15:DRAW 640,y:NEXT:'suelo casas   
1130 PLOT 4,32*2-4,12:DRAW 632,32*2-4:'separador2
1135 PLOT 4,2,2:DRAW 632,2:'separador negro
1140 PLOT 4,4,12:DRAW 4,32*2-4:PLOT 632,4,2:DRAW 632,32*2-4:' verticales
1145 WINDOW 1,20,1,25
1150 CALL &BBE4,1,1,1,1,1,1,1,1
1155 TAG:PLOT -8,-1,2: MOVE 4*32-4,3*16-2:PRINT "3D RACING ONE";:TAGOFF
1160 PAPER 8:PEN 4:LOCATE 5,23:PRINT CHR$(22)+CHR$(1);:PRINT "3D RACING ONE";CHR$(22)+CHR$(0)
1165 cad$="SPEED":|PRINTAT,0,190,2,@cad$
1170 |SETUPSP,26,0,1:|SETUPSP,26,9,26:FOR i=1 TO 15:|PRINTSP,26,190,27-i:NEXT:|SETUPSP,26,9,26
1175 cad$="MOTOR":|PRINTAT,0,190,29,@cad$
1180 |SETUPSP,27,0,1:|SETUPSP,27,9,24:FOR i=1 TO 20:|PRINTSP,27,190,60-i:NEXT:|SETUPSP,27,9,25: damage=0
1185 cad$="TIME:":|PRINTAT,0,190,61,@cad$
1190 RETURN
1195 '---- SCORE Y HALL of fame ----
1200 |MUSICOFF:|SETLIMITS,0,80,0,200
1205 MODE 0:GOSUB 705:INK 8,0:INK 0,0:INK 13,15:INK 4,6
1210 PAPER 2:CLS:GOSUB 2270
1215 TAG:PLOT -10,-10,12: MOVE 4*32-4,24*16-2:PRINT "3D RACING ONE";:TAGOFF
1220 PAPER 2:PEN 5:LOCATE 5,2: PRINT CHR$(22)+CHR$(1);"3D RACING ONE";CHR$(22)+CHR$(0);
1225 c$=" BY JOSE JAVIER GARCIA ARANDA": |PRINTAT,0,3*8,3*4,@c$
1230 c$="A FULLY BASIC PROGRAM CREATED WITH 8BP": |PRINTAT,0,5*8,2,@c$
1235 c$="THE ULTIMATE SET OF": |PRINTAT,0,6*8,5*4,@c$
1240 c$="RSX COMMANDS FOR GAMES!": |PRINTAT,0,7*8,4*4,@c$
1245 c$="WWW.GITHUB.COM/JJARANDA13/8BP": |PRINTAT,0,8*8,3*4,@c$
1250 c$="WWW.8BITSDEPODER.BLOGSPOT.COM": |PRINTAT,0,9*8,3*4,@c$
1255 GOSUB 1315: LOCATE 10,1
1260 c$= "HALL OF FAME"
1265 d$= "            "
1270 x=7*4:y=11*8: incy=0:incx=1:yant=y:xant=x
1275 '--- hall of fame---
1280 |PRINTAT,0,yant,xant,@d$:CALL &BD19:|PRINTAT,0,y,x,@c$
1285 incy=incy+1:IF incy=6 THEN incy=-5 
1290 yant=y:y=y+incy
1295 xant=x:x=x+incx:IF x>54 OR x<0 THEN incx=-incx
1300 IF INKEY(47)=0 THEN 265: 'jugar
1305 b=1+b MOD 10000: IF b>3000 THEN 55:'go intro
1305 b=1+b:IF b>3000 THEN b=0:goto 55:'go intro
1310 GOTO 1280
1315 '--- print SCORE TABLE ---
1320 xini=5*4: yini=14: dot$="........"
1325 FOR i=0 TO 10 
1330 cad$=STR$(pts(i))
1335 |PRINTAT,0,(i+yini)*8,xini,@name$(i):|PRINTAT,0,(i+yini)*8,xini+8*2,@dot$:|PRINTAT,0,(i+yini)*8,xini+16*2,@cad$
1340 NEXT i
1345 RETURN
1350 '--- CONSTRUCCION NIVEL 2 ---
1355 y=0:x=320
1360 ptr=c2: ptrend=c2end
1365 ruta8=&84B4: r=ruta8
1370 'bucle de construccion
1375 IF y>=3900 THEN GOTO 1425: ' final de carretera
1380 READ d :'por cada d, se crean dos segmentos a cada lado
1385 IF d<=4 THEN GOSUB 1445:' crea segmentos blanco y rojo
1390 IF d=10 THEN difx=-30:difx2=difx+3:GOSUB 1505:' crea cartel izq
1395 IF d=11 THEN difx=80+40:difx2=difx-3:GOSUB 1505:' crea cartel dere
1400 ' construccion de la ruta para los coches. ruta8=&84b4. cada tramo mide 100 pues son 2 segmentos (uno blanco y uno rojo)
1405 IF d<-1 THEN POKE r, 253:r=r+1:|POKE,r,68:r=r+2:POKE r,10:r=r+1: POKE r,&F6:r=r+1:POKE r,((d*2) AND 255):r=r+1:' 10 pasos de vy=-10 (en una linea)
1410 IF d>1 AND d<5 THEN POKE r, 253:r=r+1:|POKE,r,67:r=r+2:POKE r,10:r=r+1: POKE r,&F6:r=r+1:POKE r,((d*2) AND 255):r=r+1:' 10 pasos de vy=-10 (en una linea)
1415 IF d>=-1 AND d<=1  THEN POKE r, 253:r=r+1:|POKE,r,66:r=r+2:POKE r,10:r=r+1: POKE r,&F6:r=r+1:POKE r,((d*2) AND 255):r=r+1:' 10 pasos de vy=-10 (en una linea)
1420 GOTO 1370
1425 ' crea final carretera---
1430 POKE r,0
1435 d=0:GOSUB 1445:GOSUB 1445:GOSUB 1445:GOSUB 1445' 300 metros mas para el final
1440 RETURN
1445 '--- crea blanco y rojo -----
1450 x=x+10*d
1455 IF d<0  THEN im=28 +4-d
1460 IF d>=0 THEN im=d+28
1465 |POKE,ptr,y:|POKE,ptr+2,x: |POKE,ptr+4,im
1470 |POKE,ptr+6,y:|POKE,ptr+8,x+80: |POKE,ptr+10,im+18
1475 ptr=ptr+12: y=y+50:
1480 x=x+10*d
1485 |POKE,ptr,y:|POKE,ptr+2,x: |POKE,ptr+4,im+9
1490 |POKE,ptr+6,y:|POKE,ptr+8,x+80: |POKE,ptr+10,im+9+18
1495 ptr=ptr+12: y=y+50
1500 RETURN
1505 ' ---crea cartel ------
1510 |POKE,ptr,y:|POKE,ptr+2,x+difx: |POKE,ptr+4,cartelzoom
1515 ptr=ptr+6
1520 |POKE,ptr,y+11:|POKE,ptr+2,x+difx2: |POKE,ptr+4,campozoom
1525 ptr=ptr+6
1530 RETURN
1535 '--- datos nivel 2 ---
1540 DATA 0,0,0,0, 1,10,11,-1, 10,1,1,-1, -1,1,2,3, 4,3,2,1
1545 DATA 0,0,0,-1, -2,-3,-4,-3, -2,-1,-1,1, 0,-1,-1,0 ,1,1,0,0 
1550 DATA 0,0
1555 |UMAP,c, cend,y,y+550,0,600
'1560 POKE &B8B4,0:POKE &B8B5,0:POKE &B8B6,0:POKE &B8B7,0:A=TIME
1565 |PRINTSPALL,0,0,0
1570 |AUTOALL,1
1575 ' --- CICLO JUEGO FASE 2---
1580 y=y+vy:x=x+dx:|MOVERALL,vy,-dx:col=PEEK (coli)+PEEK(cold):IF col THEN IF vy>1 THEN damage=damage+1:INK 8,3:GOTO 1590 ELSE col=0
1585 IF INKEY(67) THEN 1590 ELSE |MOVER,22,flag,0:flag=-flag:IF vy<14 THEN vy=vy+1:|MOVER,26,0,1:GOTO 1595 ELSE 1595
1590 IF vy THEN vy=vy-1:|MOVER,26,0,-1
1595 IF INKEY(34) THEN 1600 ELSE img=carl:IF dx>-6 THEN dx=dx-1:IF dx>0 THEN SOUND 4,50,18,7,0,1:GOTO 1615 ELSE 1615 ELSE 1615
1600 IF INKEY(27) THEN 1605 ELSE img=carr:IF dx<6 THEN dx=dx+1:IF dx<0 THEN SOUND 4,50,18,7,0,1:GOTO 1615 ELSE 1615 ELSE 1615
1605 IF dx THEN 1615 
1610 img=car
1615 IF imgant-img THEN |SETUPSP,22,9,img:imgant=img
1620 SOUND 1,s(vy),17,7:|MAP2SP,y,x:|AUTOALL:|PRINTSPALL
1625 t1=1+t1 AND 15:IF t1 THEN 1640
1630 t=t-1:IF t>9 THEN t$=STR$(t) ELSE t$=STR$(t)+" "
1635 |PRINTAT,0,190,70,@t$:IF t THEN 1660 ELSE 535
1640 IF t1-6 THEN 1650
1645 |UMAP,c,cend,y,y+425,0,1000:GOTO 1660
1650 IF y>=3900 THEN y=y-3900:|UMAP,c,cend,y,y+450,0,1000::distance=distance +3900:GOTO 1660
1655 IF t1 AND 1 THEN GOSUB 1680 
1660 IF col THEN INK 8,5:SOUND 2,3000,10,7,0,0,1:IF damage<20 THEN |MOVER,27,0,1:col=0 ELSE 535
1665 GOTO 1580
1675 '--- update coches coord y montanas ----
1680 e=1+ e AND  3: es=21-e
1685 |PEEK,dir(e),@ey:dy=ey-posy
1690 IF dx THEN 1710
1695 IF dy > 2000 THEN |MOVER,es,-3900,0:RETURN
1700 IF dy < -2000 THEN |MOVER,es,3900,0
1705 RETURN
1710 IF dx>0 THEN posm=posm+1 ELSE posm=posm-1
1715 |PRINTSP,28,51,10-posm:|PRINTSP,28,51,40-posm:|PRINTSP,28,51,60-posm
1720 GOTO 1695
1725 ' level  3
1730 cad$="LEVEL 3 : SUPERFAST": GOSUB 300
1735 RESTORE 1895: GOSUB 1350: 'crea nivel 3
1740 GOSUB 915
1745 FOR i=18 TO 21: |SETUPSP,i,0,0:NEXT
1750 c=c2:cend=c2end:distance=0
1755 FOR i=23 TO 25:|SETUPSP,i,0,0:NEXT:'quito nubes
1760 y=0: x=210
1765 GOTO 1770
1770 ' --- INIT FASE 3 ---
1775 |UMAP,c, cend,y,y+550,0,600
'1780 POKE &B8B4,0:POKE &B8B5,0:POKE &B8B6,0:POKE &B8B7,0:A=TIME
1785 |PRINTSPALL,0,0,0: distance=0
1790 |AUTOALL,1
1795 ' --- CICLO JUEGO FASE 3---
1800 y=y+vy:x=x+dx:col=PEEK (coli)+PEEK(cold):IF col THEN IF vy>1 THEN damage=damage+1:INK 8,3:GOTO 1810 ELSE col=0
1805 IF INKEY(67) THEN 1810 ELSE |MOVER,22,flag,0:flag=-flag:IF vy<30 THEN vy=vy+1:k=vy AND 1:|MOVER,26,0,k:GOTO 1815 ELSE 1815
1810 IF vy THEN vy=vy-1:k=vy AND 1:|MOVER,26,0,-k
1815 IF INKEY(34) THEN 1820 ELSE img=carl:|MOVERALL,0,1:IF dx>-7 THEN dx=dx-1:IF dx>0 THEN SOUND 4,50,16,7,0,1: GOTO 1835 ELSE 1835 ELSE 1835
1820 IF INKEY(27) THEN 1825 ELSE img=carr:|MOVERALL,0,-1:IF dx<7 THEN dx=dx+1:IF dx<0 THEN SOUND 4,50,16,7,0,1: GOTO 1835 ELSE 1835 ELSE 1835
1825 IF dx THEN 1835 
1830 img=car
1835 IF imgant-img THEN |SETUPSP,22,9,img:imgant=img
1840 SOUND 1,s(vy),15,7:|MAP2SP,y,x:|PRINTSPALL
1845 t1=1+t1 AND 15:IF t1 THEN 1860
1850 t=t-1:IF t>9 THEN t$=STR$(t) ELSE t$=STR$(t)+" "
1855 |PRINTAT,0,190,70,@t$: IF t THEN 1875 ELSE 535
1860 IF t1-8 THEN 1870
1865 |UMAP,c, cend,y,y+650,0,1000:GOTO 1875
1870 IF y>3900 THEN y=y-3900:|UMAP,c,cend,y,y+650,0,1000:distance=distance +3900 
1875 IF col THEN INK 8,5: SOUND 2,3000,10,7,0,0,1:IF damage<20 THEN |MOVER,27,0,1:col=0 ELSE 535
1880 GOTO 1800

1890 ' datos level 3
1895 DATA 0,0,0,0, 1,1,1,1, 2,2,2,2, 0,0,0,0, 0,0,0,0
1900 DATA -1,-1,-1,-1, -2,-2,-2,-2, 0,0,0,0, 0,0,0,0
1905 DATA 0,0,0
1910 ' level 4 : night
1915 cad$="LEVEL 4 : NIGHT DRIVING": GOSUB 300
1920 INK 7,0:INK 1,1:INK 0,0:INK 12,0: INK 6,2: INK 15,13:INK 14,13
1925 RESTORE 2105: GOSUB 1350: 'crea nivel 4
1930 GOSUB 915:'marcadores y terreno
1935 INK 7,0:INK 1,1:INK 0,0:INK 12,0: INK 6,2: INK 15,5:INK 14,13:INK 2,1
1940 FOR i=18 TO 21: |SETUPSP,i,0,0:NEXT
1945 c=c2:cend=c2end:distance=0
1950 FOR i=23 TO 25:|SETUPSP,i,0,0:NEXT:'quito nubes
1955 y=0: x=210
1960 WINDOW 1,20,1,7:PAPER 0:CLS:'cielo
1965 FOR star=0 TO 39 : POKE 42540+star*2,RND*50:POKE 42540+star*2+1,RND*80:NEXT
1970 |STARS,0,10,13,0,0
1975 GOTO 1980
1980 ' --- INIT FASE 4 ---
1985 |UMAP,c, cend,y,y+550,0,600
'1990 POKE &B8B4,0:POKE &B8B5,0:POKE &B8B6,0:POKE &B8B7,0:A=TIME
1995 |PRINTSPALL,0,0,0: distance=0
2000 |AUTOALL,1
2005 ' --- CICLO JUEGO FASE 4---
2010 y=y+vy:x=x+dx:col=PEEK (coli)+PEEK(cold):IF col THEN IF vy>1 THEN damage=damage+1:INK 8,3:GOTO 2020 ELSE col=0
2015 IF INKEY(67) THEN 2020 ELSE |MOVER,22,flag,0:flag=-flag:IF vy<20 THEN vy=vy+1:k=vy AND 1:|MOVER,26,0,k:GOTO 2025 ELSE 2025
2020 IF vy THEN vy=vy-1:k=vy AND 1:|MOVER,26,0,-k
2025 IF INKEY(34) THEN 2030 ELSE |STARS,0,10,13,0,-1:img=carl:|MOVERALL,0,1:IF dx>-7 THEN dx=dx-1:IF dx>0 THEN SOUND 4,50,16,7,0,1: GOTO 2045 ELSE 2045 ELSE 2045
2030 IF INKEY(27) THEN 2035 ELSE |STARS,0,10,13,0,1:img=carr:|MOVERALL,0,-1:IF dx<7 THEN dx=dx+1:IF dx<0 THEN SOUND 4,50,16,7,0,1: GOTO 2045 ELSE 2045 ELSE 2045
2035 IF dx THEN 2045 
2040 img=car
2045 IF imgant-img THEN |SETUPSP,22,9,img:imgant=img
2050 SOUND 1,s(vy),15,7:|MAP2SP,y,x:|PRINTSPALL
2055 t1=1+t1 AND 15:IF t1 THEN 2070
2060 t=t-1:IF t>9 THEN t$=STR$(t) ELSE t$=STR$(t)+" "
2065 |PRINTAT,0,190,70,@t$: IF t THEN 2085 ELSE 535
2070 IF t1-8 THEN 2080
2075 |UMAP,c, cend,y,y+650,0,1000:GOTO 2085
2080 IF y>3900 THEN y=y - 3900:|UMAP,c, cend,y,y+650,0,1000 : distance=distance +3900 
2085 IF col THEN INK 8,5: SOUND 2,3000,10,7,0,0,1:IF damage<20 THEN |MOVER,27,0,1:col=0 ELSE 535
2090 GOTO 2010
2100 ' datos level 3
2105 DATA 0,0,0,0, 1,2,2,2, -2,-2,-2,-1, 0,1,-1,1, -1,1,-1,0
2110 DATA 2,2,-2,-2, 2,-2,2,-2, 1,1,-1,-1, 0,0,0,0
2115 DATA 0,0,0,0
2120 ' rutina update tabla scores
2125 GOSUB 2270: j=11
2130 FOR star=0 TO 39 : POKE 42540+star*2,RND*200:POKE 42540+star*2+1,RND*80:NEXT
2135 FOR i=10 TO 0 STEP -1
2140 IF pts(i)<=score THEN j=i
2145 NEXT
2150 IF j=11 THEN 2265
2155 ' update score
2160 FOR i=9 TO j STEP -1
2165 name(i+1)=name(i): pts(i+1)=pts(i)
2170 NEXT
2175 MODE 0: INK 4,26:you$="":|MUSIC,2,6
2180 PAPER 2:PEN 12:LOCATE 9,20:FOR k=1 TO 6:PRINT CHR$(&8F);:NEXT
2185 LOCATE 11,19:FOR k=1 TO 2:PRINT CHR$(&8F);:NEXT
2190 |3D,0:|SETUPSP,0,9,71:|PRINTSP,0,16*8,10*4+2
2195 cad$="ENTER YOUR NAME:"
2200 |PRINTAT,0,24,20,@cad$
2205 FOR letras=1 TO 8
2210 b$=INKEY$:IF b$<>"" THEN 2210:'limpia buffer
2215 |STARS,0,20,12,2,0:|STARS,20,20,6,1,0:b$=INKEY$:b$=UPPER$(b$):IF b$="" THEN 2215
2220 IF ASC(b$)<48 THEN b$="."
2225 |PRINTAT,0,38,20+letras*2,@b$: you$=you$+b$
2230 NEXT
2235 name$(j)=you$: pts(j)=score:dir=22000
2240 FOR i=0 TO 10
2245 FOR j=0 TO 7:POKE dir+j,ASC(MID$(name$(i),j+1,1)):NEXT
2250 dir=dir+8
2255 |POKE,dir,pts(i):dir=dir+2
2260 NEXT 
2265 RUN
2270 '--- read SCORE TABLE ---
2275 dir=22000
2280 FOR i=0 TO 10: name$(i)=""
2285 FOR j=dir TO dir +7
2290 letra=PEEK (j): name$(i)=name$(i)+CHR$(letra)
2295 NEXT j: dir=dir+8
2300 pts(i)=0:|PEEK,dir,@pts(i):dir=dir+2: cad$=STR$(pts(i))
2305 NEXT i
2310 RETURN