Let's Go Racing with 7 Lines of Code

 My recent type-in Death Valley is a favourite of mine. Games like it efficiently use the text screen auto-scrolling to great a fast action game in just a short bit of code. I thought it would be fun to write such a game from scratch and getting it going on the Dragon and the BBC.

It only takes a few lines, and with just minor changes it runs on the BBC too. With 40 columns rather than 32, the Beeb is slightly easier to get a higher score.

The Dragon version will, of course, run on the Coco but not the MC-10 which sadly lacks the STRING$ function and ELSE.



BBC Basic

10 L=0:R=39:D=16:S=0:CLS
20 PRINT STRING$(L+1,"X") + STRING$(D-(L+1)," ")+ "V"+ STRING$(R-(D+1)," ")+STRING$(40-(R),"X");
30 A$=INKEY$(0):IFA$="Q"THEND=D-1:IF D<1 THEN D=1
40 IFA$="P"THEN D=D+1:IF D>38 THEN D=38
50 IFRND(10)=1THEN L=L+1 
60 IFRND(10)=1THEN R=R-1
70 S=S+1:IFD=L OR D=R THEN CLS:PRINT "CRASH!!":PRINT "SCORE:":PRINT S:STOP ELSE GOTO 20

Dragon / Tandy Coco

10 L=0:R=31:D=16:S=0:CLS
20 PRINT STRING$(L+1,"X") + STRING$(D-(L+1)," ")+ "V"+ STRING$(R-(D+1)," ")+STRING$(32-(R),"X");
30 A$=INKEY$:IFA$="Q"THEND=D-1:IF D<1 THEN D=1
40 IFA$="P"THEN D=D+1:IF D>30 THEN D=30
50 IFRND(10)=1THEN L=L+1 
60 IFRND(10)=1THEN R=R-1
70 S=S+1:IFD=L OR D=R THEN CLS:PRINT "CRASH!!":PRINT "SCORE:":PRINT S:STOP ELSE GOTO 20

Might see if I can get this one running on other systems! Drive safely now...

No comments:

Post a Comment

Magic Mirror On The Screen

Well this doesn't need much explanation either... mirroring. Again the buttons aren't amazing but are functional.  The code is on  G...