2016 BASIC 'Tenliners' contest – My very first 10-liner is for the MSX

type-heroIf you follow our (almost) daily posts, you probably saw one about the 2016 BASIC Tenliner contest, that is happening right now until March 28th.

After reading the appeal made on MSX Resource Center, calling for MSX programmers to participate in the contest, I decided to listen and give my contribution. The only caveat is that I never had done any BASIC programming for the MSX!

I already had installed on my Mac CocoaMSX emulator in order to test the games I check for Vintage is The New Old, so I just needed to learn a bit about MSX BASIC.

As any Microsoft BASIC, the MSX dialect is pretty straightforward in terms of string manipulation and other commands. A nice surprise was the PLAY command, which allows me to add a (bad) background music without blocking the program execution.

The gameplay is similar to music games like Guitar Hero. On this 10-line version, numbers from 1 to 5 will scroll up in random sequence. The player has to type the correspondent number when it is printed on the line marked. Every right keystroke gives the user 10 points. A wrong keystroke makes you lose a life.

The player starts with 10 lives and after every 100 points, the scroll speed will increase. The game is over when the player is out of lives.

The game is pretty simple, but I believe I managed to make it very compact yet complete. Here it is:

10 CLS:WIDTH40:DIM L$(10),R$(10):FOR I=1 TO 10:L$(10)=STRING$(10.32):LOCATE 1,17:PRINT STRING$(14,255);
20 PS=200:LF=10:CL= 2:SC=0:LOCATE 26,17 :PRINT STR1NG$(14,255);:LOCATE17,1:PRINT"TYPE HERO":C$="&"
30 FOR 1=1 TO 10:LOCATE15,I+14:PRINTL$(I);:NEXT
40 K$=INKEY$:IF K$<>"" AND K$=R$(2) THEN SC=SC+10:ELSE IF K$<>"" THEN LF=LF-1
50 P=INT(RND(1)*5)+4:R$(10)=CHR$(RND(1)*5)+49):MID$(L$(10),P,1)=R$(10)
60 FOR 1=2 TO 10:L$(I-1)=L$(I):R$(I-1)=R$(I):NEXTI:L$(10)=" "
70 IF NOT PLAY(0) THEN PLAY"L16O4GO5CO4BAGFGGGFGABO5L4C"
80 IFLF=0THEN LOCATE 17,8:PRINT"GAME OVER!!":END:ELSE:LOCATE1,6:PRINT"LIFE: ";STRING$(LF,198);STRING$(10," ")
90 IF SC>0 AND ((SC/100)-INT(SC/100)=0) THEN PS=PS-20:CL=CL+1:COLOR1,CL:IF CL=15 THEN CL=2
100 LOCATE 1,5:PRINT"SCORE: ";SC:FORP=1TOPS:NEXTP:GOTO 30

Link: Tenliners Contest

Author: Paulo Garcia

2 thoughts on “2016 BASIC 'Tenliners' contest – My very first 10-liner is for the MSX

Leave a Reply

Your email address will not be published. Required fields are marked *