Jump to content
Sign in to follow this  
tibasic

TI Basic game in development: Lasergate

Recommended Posts

Posted (edited)

I have been developing a 3D type game in TI Basic. In this game you pilot a helicopter through some laser gates. The number of points awarded depends how close horizontally you pass to the centre of the gate. You get a maximum of 5 points and there are 20 gates so theoretically you could get 100 points but I'm not sure if that's possible.

 

I've tested it on Classic99 and Js99'er. The code is included below if you want to copy and paste it into one of the emulators.

 

There are a few small issues to iron out but it seems to working ok.

 


100 RANDOMIZE
110 CALL CLEAR
120 CALL SCREEN(2)
130 FOR I=1 TO 16
140 CALL COLOR(I,16,1)
150 NEXT I
160 GOSUB 1070
170 INPUT "PRESS ENTER TO PLAY":ENTER$
180 CALL CLEAR
190 X=0
200 Y=1
210 XPOS=17
220 T=0
230 H=0
240 H2=0.8
250 GATE=0
260 SC=0
270 SHIP=10
280 CALL CHAR(128,"FFFFFFFFFFFFFFFF")
290 CALL CHAR(136,"FF")
300 CALL CHAR(144,"FE10387C7C3844C6")
310 CALL SCREEN(2)
320 CALL COLOR(13,3,1)
330 CALL COLOR(14,7,1)
340 CALL COLOR(15,16,1)
350 CALL KEY(0,K,S)
360 IF K=88 THEN 370 ELSE 380
370 Y=Y-(Y<=10)
380 IF K=69 THEN 390 ELSE 400
390 Y=Y+(Y>=1)*2
400 IF K=68 THEN 410 ELSE 420
410 X2=-1
420 IF K=83 THEN 430 ELSE 440
430 X2=1
440 X=X+X2
450 YPOS=24-(T+8)*(10-Y)/10-Y
460 IF XPOS-T+X-1<1 THEN 480
470 CALL VCHAR(YPOS,XPOS-T+X-1,128,T)
480 IF XPOS+T+X>32 THEN 500
490 CALL VCHAR(YPOS,XPOS+T+X,128,T)
500 L=0
510 IF XPOS-T+X-1>=1 THEN 530 ELSE 550
520 L=XPOS-T+X
530 CALL HCHAR(YPOS+T*H,XPOS-T+X,136,2*T+L)
540 CALL HCHAR(YPOS+T*H2,XPOS-T+X,136,2*T+L)
550 CALL HCHAR(17,16,144)
560 T=T+1
570 IF T<>10 THEN 890
580 IF (18>=INT(YPOS+T*H))*(18<=INT(YPOS+T*H2))THEN 590 ELSE 670
590 IF (16<XPOS-T+X-1)+(16>XPOS+T+X)THEN 670
600 CALL CLEAR
610 SC=SC+INT(5-ABS(16-(XPOS+X-1)))
620 PRINT "POINTS:";INT(5-ABS(16-(XPOS+X-1)));"SCORE:";SC
630 FOR L=0 TO 16 STEP 2
640 CALL SOUND(-50,700,L,2100,L,4200,L)
650 NEXT L
660 GOTO 750
670 CALL CLEAR
680 CALL SOUND(300,500,0)
690 CALL SOUND(300,110,0)
700 SHIP=SHIP-1
710 IF SHIP=-1 THEN 910
720 PRINT ::"REMAINING SHIPS:";SHIP
730 FOR I=1 TO 1000
740 NEXT I
750 GATE=GATE+1
760 IF GATE<>15 THEN 780
770 PRINT :::"FIVE GATES REMAINING!"::::::
780 IF GATE=20 THEN 910
790 CALL COLOR(15,16,1)
800 XPOS=INT(RND*22)+5
810 CALL CLEAR
820 T=0
830 X=0
840 H=RND*(0.5+0.015*GATE)
850 H2=H+0.5-0.015*GATE
860 IF H2-H<0.2 THEN 840
870 CALL COLOR(14,INT(H*10)+3,1)
880 CALL COLOR(14,INT(H*10)+3,1)
890 CALL CLEAR
900 GOTO 350
910 CALL CLEAR
915 BONUS=0
920 FOR I=1 TO SHIP
925 BONUS=BONUS+10
930 PRINT "BONUS POINTS:";BONUS
940 FOR L=0 TO 12 STEP 2
950 CALL SOUND(-50,350,L,1050,L,2100,L)
960 NEXT L
970 SC=SC+10
975 CALL CLEAR
980 NEXT I
990 PRINT :::"YOUR SCORE IS:";SC::::
1000 PRINT "PLAY AGAIN Y OR N?"
1010 CALL KEY(0,K,S)
1020 IF S=0 THEN 1010
1030 IF K=ASC("Y")THEN 180
1040 IF K=ASC("N")THEN 1060
1050 GOTO 1010
1060 END
1070 DIM A$(16)
1080 A$(1)="0000000000000000"
1090 A$(2)="000000000F0F0F0F"
1100 A$(3)="00000000F0F0F0F0"
1110 A$(4)="00000000FFFFFFFF"
1120 A$(5)="0F0F0F0F00000000"
1130 A$(6)="0F0F0F0F0F0F0F0F"
1140 A$(7)="0F0F0F0FF0F0F0F0"
1150 A$(8)="0F0F0F0FFFFFFFFF"
1160 A$(9)="F0F0F0F000000000"
1170 A$(10)="F0F0F0F00F0F0F0F"
1180 A$(11)="F0F0F0F0F0F0F0F0"
1190 A$(12)="F0F0F0F0FFFFFFFF"
1200 A$(13)="FFFFFFFF00000000"
1210 A$(14)="FFFFFFFF0F0F0F0F"
1220 A$(15)="FFFFFFFFF0F0F0F0"
1230 A$(16)="FFFFFFFFFFFFFFFF"
1240 FOR I=1 TO 16
1250 CALL CHAR(96-1+I,A$(I))
1260 NEXT I
1270 PRINT "kd``````````````````````````"
1280 PRINT "oj`````````LASERGATE````````"
1290 PRINT "oj``````````````````````````"
1300 PRINT "oo````````KEYS:`E`DOWN``````"
1310 PRINT "mob`````````````X`UP````````"
1320 PRINT "eok`````````````S`LEFT``````"
1330 PRINT "`moc```locb`````D`RIGHT`````"
1340 PRINT "``doob```dlocb``````````````"
1350 PRINT "```dookb``c`lmokb```````````"
1360 PRINT "`````monc`ookcoomlkcb```````"
1370 PRINT "``````monogoooooob```llac```"
1380 PRINT "```````docnooooooo```````dlk"
1390 PRINT "````````dooooooookb`````````"
1400 PRINT "``````````mooooooooc````````"
1410 PRINT "`FLY THRU``mooooookek```````"
1420 PRINT "```THE``````dmooooooob``````"
1430 PRINT "`GATES`````dbmnoooooogb`````"
1440 PRINT "``CLOSE``````idamoooooj`````"
1450 PRINT "`TO`THE```````dcloooooo`````"
1460 PRINT "```CENTRE```````h`llonlh````"
1470 PRINT ::
1480 RETURN

js99er-20210512145828.png

Edited by tibasic
Update program listing
  • Like 11

Share this post


Link to post
Share on other sites

Classic99 should be SEXD responsive! The game is a bit slow so maybe it doesn't look like anything is happening. Also you may want to swap around the E and X keys as I have the game configured so E is down and X is up. The line 340 and 360 could be changed as follows.

 

340 IF K=ASC("E") THEN 350 ELSE 360

360 IF K=ASC("X") THEN 370 ELSE 372

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)

Actually for a TI BASIC game it's quite responsive. Impressive! One can, and in many cases needs to, press more than one key at a time to make it through the gate in time. If you wait to correct your position in one direction first before correcting in the other, then you will miss the gate entirely.

I did get a Bad Value in 410 error, which looks like a screen coordinates boundary issue.

Edited by Vorticon
  • Like 2

Share this post


Link to post
Share on other sites
Posted (edited)

Cool game!

When I understood how to fly it was cool. Played it and the last two I just let play out to end the game. And on the last life I got this feedback.
 

Lasergate Bad value in 410 2.png

 

Edited by oddemann
Pic with values
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

Thanks Vorticon and oddemann for trying the game and finding the errors. I thought I'd fixed the coordinate errors before I posted the game but it's great that you found them.

 

All that is needed it seems are some small changes to lines 395 and 405.

 

To correct the program the first minus sign in line 395 needs to be changed to a plus and in line 405 "ELSE 430" needs to be added to the end. The new lines are listed below and could be copy-pasted into the version listed above or could be done manually as they are very small changes. Hopefully it works better now!

 

New lines:

395 IF XPOS+T+X-1>32 THEN 404

405 IF XPOS-T+X-1>=1 THEN 410 ELSE 430

 

Once it's all working properly I'll attach the full corrected version to the first post.

 

Edited by tibasic
  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

Thanks again oddemann. I think the line needs to be:

 

395 IF XPOS+T+X>32 THEN 404

Share this post


Link to post
Share on other sites

PS! You should update it every time on top...

Why? Testing it now I copied the new lines and then copied the top... NOT thinking that THEN I deleted the first two lines I put in :p hehehe. So I think it is best to update the top one as soon as you update.

It is working for me, tried 2 times and no error. So doing it right, looks like you have a "running" game ;)

  • Like 3

Share this post


Link to post
Share on other sites

Probably more pedantic than practical, but a recommendation to help with speed would be to use the ASCII values of the keys rather than comparing K to the ASC() result of a literal character.  ~1 second over 100 iterations versus ~3 seconds, respectively.  Reducing the iterations to 10 produces near instant results versus ~1 second.

  • Like 2

Share this post


Link to post
Share on other sites

I've updated the program listing in the first post that has the fix for the coordinate errors. I also changed the keys to the ascii codes and updated the title screen to inform what directions the keys are for.

 

I noticed that the game awards very high negative points if you fly to the side of the gates. I'll have to fix that and then it'll be ready I think.

  • Like 2

Share this post


Link to post
Share on other sites

I've fixed the high negative points situation.

 

Additionally I have added a bonus points system to the game. You now get extra bonus points added to your score at the end depending on how many ships you have left. There is also a '5 gates remaining' message in the game so you know how many gates are left to go through. I've updated the listing in the first post.

 

When the gate goes partly off the screen it either disappears or wraps around to the other side of the screen. It's a bit messy looking so I might have a go at fixing that. 

 

  • Like 3

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...