Jump to content
Sign in to follow this  
nanochess

Cannonball game ported

Recommended Posts

Hi.

 

Yesterday I saw the Retrobattlestations challenge to show your machine running a BASIC program provided by @fozztexx.

 

The TI-99/4A wasn't in the ports, so I had to port it from PET BASIC, had a difficult time because BX% and BX were different names of variables and the % ones were integers, also because it was my first time using CALL functions.

 

But finally today I got the game working.

 

https://www.youtube.com/watch?v=mlNrd2YOY40

 

Link to Retrobattlestations challenge https://www.reddit.com/r/retrobattlestations/comments/8w49tm/contest_basic_month_3_cannonball/

 

 

 

100 REM === BASIC MONTH 3: CANNONBALL
110 REM === HTTP://REDDIT.COM/R/RETROBATTLESTATIONS
120 REM === WRITTEN BY FOZZTEXX
130 REM === TI-99/4A VERSION BY NANOCHESS (JUL/08/2018)
200 REM === CLEAR SCREEN AND SETUP VARIABLES
210 CALL CLEAR
220 CL = 32
225 RW = 24
230 CA = 45
235 CN = 5
240 CX = 5
242 PX = CL-5
244 SC = 0
246 LV = 3
250 PI = 3.14159
260 RANDOMIZE
270 GOTO 310
300 REM === PLAY GAME
305 SC = SC + 10
310 CV = INT(RND * 15) + 10
312 GOSUB 4010
314 GOSUB 2010
320 GOSUB 2510
330 IF K$ <> "E" THEN 340
332 CA = CA + 5
334 IF CA < 85 THEN 340
336 CA = 85
340 IF K$ <> "X" THEN 350
342 CA = CA - 5
344 IF CA > 15 THEN 350
346 CA = 15
350 IF K$ = "Q" THEN 390
360 IF K$ = " " THEN 410
370 GOSUB 1010
380 GOTO 320
390 END
400 REM === FIRE!
410 LX = (CN + 1) * COS((360 - CA) * PI / 180) + 0.5
415 LY = (CN + 1) * SIN((360 - CA) * PI / 180) + 0.5
420 BX = CX + LX
425 BY = RW + LY
430 GOSUB 1510
440 VX = CV * COS((360 - CA) * PI / 180)
445 VY = CV * SIN((360 - CA) * PI / 180)
500 REM === MOVE PLAYER AND ANIMATE BALL
510 GOSUB 2510
520 IF K$ <> "S" THEN 530
522 PX = PX - 1
524 IF PX >= CX+CN THEN 530
526 PX = CX+CN
530 IF K$ <> "D" THEN 540
532 PX = PX + 1
534 IF PX <= CL - 1 THEN 540
536 PX = CL -1
540 GOSUB 2010
550 BX = BX + (VX / 10)
552 BY = BY + (VY / 10)
554 GOSUB 1510
560 VY = VY + 2
570 IF BY < RW THEN 510
580 P$=" "
582 X1=INT(BX)
584 Y1=INT(BY)
586 GOSUB 3510
600 REM === SCORE OR DIE
610 LX = BX - OX
612 LY = BY - OY
614 L2 = RW - OY
620 IX = OX + LX * (L2 / LY)
630 IF (IX >= PX - 1)*(IX <= PX + 1) THEN 305
640 LV = LV - 1
645 GOSUB 4010
650 IF LV >= 1 THEN 310
652 P$="GAME OVER"
654 X1 = INT((CL - LEN(P$)) / 2)
656 Y1 = INT(RW / 2)
658 GOSUB 3510
660 END
1000 REM === DRAW CANNON
1010 IF (CA = LA) THEN 1075
1020 P$="ANG:"&STR$(CA)&" "
1022 X1=2
1024 Y1=1
1026 GOSUB 3510
1030 LX = CN * COS((360 - LA) * PI / 180) + 0.5
1035 LY = CN * SIN((360 - LA) * PI / 180) + 0.5
1040 X1 = CX
1042 Y1 = RW
1044 X2 = X1 + LX
1046 Y2 = Y1 + LY
1048 P$ = " "
1049 GOSUB 3010
1050 LX = CN * COS((360 - CA) * PI / 180) + 0.5
1055 LY = CN * SIN((360 - CA) * PI / 180) + 0.5
1057 X1 = CX
1059 Y1 = RW
1060 X2 = X1 + LX
1062 Y2 = Y1 + LY
1064 P$= "%"
1066 GOSUB 3010
1070 LA=CA
1075 RETURN
1500 REM === DRAW BALL
1510 X1 = INT(BX)
1512 Y1 = INT(BY)
1514 P$ = "O"
1516 GOSUB 3510
1520 IF (OX = X1)*(OY = Y1) THEN 1540
1530 X1 = OX
1532 Y1 = OY
1534 P$ = " "
1536 GOSUB 3510
1537 OX = INT(BX)
1538 OY = INT(BY)
1540 RETURN
2000 REM === DRAW PLAYER
2010 P$="U"
2012 X1 = PX
2014 Y1 = RW
2016 GOSUB 3510
2020 IF QX = X1 THEN 2040
2030 X1=QX
2032 P$=" "
2034 GOSUB 3510
2036 QX=PX
2040 RETURN
2500 REM === READ THE KEYBOARD
2510 CALL KEY(0,K,S)
2512 IF S<>0 THEN 2516
2514 K = 33
2516 K$ = CHR$(K)
2520 RETURN
3000 REM === PLOT A LINE
3010 X1 = INT(X1)
3012 X2 = INT(X2)
3014 Y1 = INT(Y1)
3016 Y2 = INT(Y2)
3020 DX = ABS(X2 - X1)
3022 SX = -1
3024 IF X1 >= X2 THEN 3030
3026 SX = 1
3030 DY = ABS(Y2 - Y1)
3032 SY = -1
3034 IF Y1 >= Y2 THEN 3040
3036 SY = 1
3040 ER = -DY
3042 IF DX <= DY THEN 3050
3044 ER = DX
3050 ER = INT(ER / 2)
3060 GOSUB 3510
3070 IF (X1 = X2)*(Y1 = Y2) THEN 3140
3080 E2 = ER
3090 IF E2 <= -DX THEN 3100
3092 ER = ER - DY
3094 X1 = X1 + SX
3100 IF (X1 = X2)*(Y1 = Y2) THEN 3140
3110 IF E2 >= DY THEN 3120
3112 ER = ER + DX
3114 Y1 = Y1 + SY
3120 IF (X1 = X2)*(Y1 = Y2) THEN 3140
3130 GOTO 3060
3140 RETURN
3500 REM === PLOT A POINT
3510 IF (X1 < 1)+(X1 > CL)+(Y1 < 1)+(Y1 > RW) THEN 3540
3520 FOR CT=1 TO LEN(P$)
3525 CALL HCHAR(Y1,X1+CT-1,ASC(SEG$(P$,CT,1)))
3528 NEXT CT
3540 RETURN
4000 REM === SHOW SCORE/LIVES/VELOCITY
4010 P$="SPD:"&STR$(CV)&" "
4012 X1 = INT(CL / 3)
4014 Y1=1
4016 GOSUB 3510
4020 P$="SCORE:"&STR$(SC)
4022 X1 = INT(CL * 2 / 3)
4024 GOSUB 3510
4030 P$=SEG$(" UUU",LV+1,3)
4032 X1=CL - 2
4034 GOSUB 3510
4040 RETURN 

 

  • Like 6

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