Jump to content
tibasic

TI Basic game development (completed) : 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.

 

Update: all the issues are fixed now. I've also attached the file for running on Classic 99 and Js99'er.

 

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

 

js99er-20210512145828.png

LASERGATE.zip

Edited by tibasic
Update program listing
  • Like 12

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

I've fixed all the issues now and the game is finished. See first post for the final version of the game.

 

Next I think I'll attempt to make a game based on Battlezone in TI Basic. Below is a side scrolling experiment I did a while ago.

 

100 FOR I=1 TO 17
110 CALL CLEAR
120 CALL COLOR(2,1,1)
130 PRINT TAB(I+10);"*"
140 PRINT TAB(I+1);"*";
150 PRINT TAB(I+9);"***"
160 PRINT TAB(I);"***";
170 PRINT TAB(I+7);"*****"
175 CALL HCHAR(24,1,42,32)
180 CALL COLOR(2,5,5)
190 NEXT I

 

  • Like 3

Share this post


Link to post
Share on other sites

Nice to see a TI Basic game, I haven't played one in ages. At first I could not get this to work on the real iron (controls seemed to have no impact) before I remembered that alpha lock must be on as the code is probably looking for upper case characters. Also discovered that my ET-PEB could not handle 9 character file names, but renaming the file made it work.

I was looking for a TI Basic program to test certain things with the StrangeCart, and I think I found what I was looking for :) 

  • Like 3

Share this post


Link to post
Share on other sites

Glad to hear you got the game working and that the program might even be useful! 🙂

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, tibasic said:

Glad to hear you got the game working and that the program might even be useful! 🙂

Yes, thanks for making it! There's definitely nostalgia at play, but I really like that there's new software requiring just the console! Of course TI Basic has huge constraints, so it is always an achievement to have something playable created with it.

  • Like 1

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.
Note: Your post will require moderator approval before it will be visible.

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...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...