tibasic Posted April 5, 2021 Share Posted April 5, 2021 (edited) Hi, It's been a while since I've written any basic games. This one is a short and simple game inspired by the 1983 Atari Star Wars arcade game. In this game you battle H fighters which are tie fighter-like ships. There is no trench run but I think it's possible to approximate. I might look into if as a separate game. I'm trying to keep my games simple these days. To score against the h fighters your laser needs to strike them in the centre. In a similar manner for the h fighter to score against you and destroy one of your 5 ships it needs to strike you when it is positioned midway horizontally. The h fighter turns magenta just before it fires its laser. In that way you will hopefully have enough time to manoeuvre out of the way. The keys are ESDX for manoeuvring and spacebar to fire. The code is in the spoiler and a file for use with Classic99 is attached. Spoiler 100 CALL CLEAR 110 PRINT " H-FIGHTER" 120 PRINT 130 PRINT "H shaped space fighters" 140 PRINT "fill up your screen and" 150 PRINT "fire their lasers at you" 160 PRINT "avoid them and fire back" 170 PRINT "with your own lasers" 180 PRINT "your score will be printed" 190 PRINT "when 5 of your ships have" 200 PRINT "been destroyed" 210 PRINT "score 10 points by shooting" 220 PRINT "at the centre of a h fighter" 230 PRINT 240 PRINT "keys:" 250 PRINT "E up":"X down":"S left":"D right":"SPACE fire"::: 260 PRINT " PRESS ANY KEY TO PLAY" 270 CALL KEY(0,K,S) 280 IF S=0 THEN 270 290 REM initialise 300 T=1 310 X=16 320 Y=0 330 LV=5 340 SC=0 350 REM chars and colours 360 CALL CHAR(128,"00003C3C3C3C0000") 370 CALL CHAR(129,"0000FFFFFFFF0000") 380 CALL CHAR(136,"0000FF0000FF0000") 390 CALL CHAR(144,"C3C3C3C3C3C3C3C3") 400 CALL SCREEN(2) 410 CALL COLOR(13,3,1) 420 CALL COLOR(14,6,1) 430 CALL COLOR(15,7,1) 440 REM start game 450 CALL KEY(0,K,S) 460 IF S=0 THEN 660 470 IF K<>32 THEN 610 480 REM player shoots 490 FOR I=0 TO 2 500 CALL HCHAR(12,I*5+2,136,5) 510 CALL HCHAR(12,26-I*5,136,5) 520 NEXT I 530 IF (Y=0)*(X<19)*(X>14)THEN 550 ELSE 610 540 REM player scores 550 CALL SOUND(300,800,0) 560 CALL SCREEN(16) 570 CALL SCREEN(2) 580 SC=SC+10 590 T=11 600 GOTO 900 610 X=X-(K=68) 620 X=X+(K=83) 630 Y=Y-(K=88) 640 Y=Y+(K=69) 650 IF (X+T>32)+(X-T<1)+(12+Y-T<2)THEN 910 ELSE 660 660 CALL CLEAR 670 REM move h fighter 680 T2=T*2 690 CALL VCHAR(12+Y-0.5*T2,X+T,128,T2) 700 CALL VCHAR(12+Y-0.5*T2,X-T,128,T2) 710 CALL HCHAR(12+Y,X-T+1,129,T2-1) 720 IF (RND>0.8)*(FLAG=0)THEN 740 ELSE 760 730 REM prepare to fire 740 CALL COLOR(13,14,1) 750 FLAG=1 760 IF (RND>0.7)*(FLAG=1)THEN 780 ELSE 890 770 REM h fighter fires 780 CALL VCHAR(12+Y+1,X,144,11-Y) 790 CALL COLOR(13,3,1) 800 FLAG=0 810 IF (X>13)*(X<19)THEN 830 ELSE 890 820 REM h fighter scores 830 LV=LV-1 840 CALL SOUND(300,110,0) 850 CALL SCREEN(3) 860 CALL SCREEN(2) 870 IF LV=0 THEN 960 880 REM increment counter 890 T=T+1 900 IF T<=10 THEN 940 910 T=1 920 X=10+INT(RND*12) 930 Y=-6+INT(RND*12) 940 GOTO 450 950 REM game over 960 CALL CLEAR 970 CALL SCREEN(4) 980 PRINT "SCORE:";SC::: 990 PRINT "PLAY AGAIN (Y/N)?" 1000 CALL KEY(0,K,S) 1010 IF S=0 THEN 1000 1020 IF K=89 THEN 300 1030 IF K=78 THEN 1050 1040 GOTO 1000 1050 END HFIGHTER.zip Edited April 5, 2021 by tibasic 14 Quote Link to comment Share on other sites More sharing options...
tibasic Posted April 13, 2021 Author Share Posted April 13, 2021 I noticed when I was playing H fighter that sometimes it would cause an bad value. This can be fixed by deleting line 650 and moving it to line 675, i.e. 675 IF (X+T>32)+(X-T<1)+(12+Y-T<2)THEN 910 ELSE 680 Also I made some progress with a game inspired by the trench run part of the Atari Star Wars game. I've called it Laser Gate because in this game you have to fly through a set of gates to score points. I've included the code below in the spoiler if you want to try it by pasting it into Classic99 or js99er. Spoiler 100 CALL CLEAR 110 PRINT " LASER GATE" 120 PRINT " **********" 130 PRINT ::: 140 PRINT " use e and x to steer":: 150 PRINT " through the laser gates":: 160 PRINT " and score 10 points":: 170 PRINT :::::::::: 180 INPUT "PRESS ENTER TO PLAY":ENTER$ 190 CALL CLEAR 200 Y=1 210 H=0 220 H2=0.8 230 GATE=0 240 CALL CHAR(128,"FFFFFFFFFFFFFFFF") 250 CALL CHAR(136,"FF") 260 CALL SCREEN(2) 270 CALL COLOR(2,2,7) 280 CALL COLOR(13,3,1) 290 CALL COLOR(14,7,1) 300 CALL KEY(0,K,S) 310 IF K=ASC("X")THEN 320 ELSE 330 320 Y=Y-(Y<=10) 330 IF K=ASC("E")THEN 340 ELSE 350 340 Y=Y+(Y>=1) 350 YPOS=24-(T+8)*(10-Y)/10-Y 360 CALL VCHAR(YPOS,16-T,128,T) 370 CALL VCHAR(YPOS,17+T,128,T) 380 CALL HCHAR(YPOS+T*H,17-T,136,2*T) 390 CALL HCHAR(YPOS+T*H2,17-T,136,2*T) 400 CALL HCHAR(17,16,43) 410 T=T+1 420 IF T<>10 THEN 580 430 IF (18>INT(YPOS+T*H))*(18<INT(YPOS+T*H2))THEN 440 ELSE 480 440 SC=SC+10 450 CALL SCREEN(16) 460 CALL SOUND(300,500,0) 470 CALL SOUND(300,1000,0) 480 GATE=GATE+1 490 IF GATE=10 THEN 610 500 CALL SCREEN(2) 510 CALL CLEAR 520 T=0 530 H=RND 540 H2=H+RND*(1.0-H) 550 IF H2-H<0.2 THEN 530 560 CALL COLOR(14,INT(H*10)+3,1) 570 CALL COLOR(14,INT(H*10)+3,1) 580 CALL CLEAR 590 CALL COLOR(2,2,INT(H*10)+3) 600 GOTO 300 610 PRINT "YOUR SCORE IS:";SC 4 Quote Link to comment Share on other sites More sharing options...
+Ksarul Posted April 14, 2021 Share Posted April 14, 2021 It is always fun to see what you do with BASIC. 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.