Author Topic: BBC Basic Tetris  (Read 14026 times)

0 Members and 1 Guest are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: BBC Basic Tetris
« Reply #15 on: June 14, 2009, 04:37:06 pm »
Ok, here's the code, although it is kinda big, and i don't know how to put it in one of those scrolling box things

Code: [Select]
  10 VDU 5
   20 R%=0:NOW%=0:NEX%=RND(7)
   30 PROC_PIECE
   40 S%=0:LVL%=14:LS%=0
   50 C%=0:HIT%=FALSE
   60 X%=44:Z%=52
   70 *FX 4,1
   80 *FX 12,1
   90 *FX 11,15
  100 *GSCALE1
  110 *REFRESH OFF
  120 GCOL0:VDU5:CLG:CLS:MOVE 1,20:PRINT " "
  130 RECTANGLE 0,0,95,3:RECTANGLE 24,0,3,64:RECTANGLE 68,0,3,64
  150 PROC_NEW
  160 GCOL4,0
  170 REPEAT
  180   PROC_DISP
  190   *REFRESH
  200   PROC_DISP
  210   C%=C%+1
  220   A%=0
  230   IF C% MOD LVL% = 0:Z%=Z%-4
  240   KEY%=INKEY(0)
  250   IF KEY%=136:X%=X%-4
  260   IF KEY%=137:X%=X%+4
  270   IF INKEY(-42):C%=-1
  280   IF KEY%=139:PROC_ROTL
  290   PROC_HIT
  300 UNTIL HIT% OR KEY%=27 OR KEY%=127
  310 IF KEY%=136:X%=X%+4
  320 IF KEY%=139 PROC_ROTR
  330 IF KEY%=137:X%=X%-4
  340 PROC_HIT
  350 IF HIT% Z%=Z%+4:PROC_DISP:PROC_LINE:PROC_NEW
  360 IF KEY%=27 PROC_END
  370 IF KEY%=127 PROC_PAUSE
  380 GOTO 160
  390 DEFPROC_PAUSE
  400 RECTANGLE FILL 0,0,96,64:*REFRESH
  410 WAIT20
  420 REPEAT UNTIL INKEY(1)>0
  430 RECTANGLE FILL 0,0,96,64
  440 ENDPROC
  450 DEFPROC_NEW                                       //Creates a new piece and updates the screen
  460 NOW%=NEX%:NEX%=RND(7)
  470 X%=44:Z%=56
  480 R%=NOW%
  490 PROC_PIECE:PROC_HIT
  500 IF HIT% PROC_END
  510 GCOLLVL%:RECTANGLE FILL 0,4,23,57:RECTANGLE FILL 72,4,23,57:GCOL15:RECTANGLE FILL 0,20,23,24:GCOL4,0
  520 GCOL15:RECTANGLE FILL 0,57,23,9:RECTANGLE FILL 72,57,23,9:GCOL0:MOVE 1,62:PRINT ;S%:MOVE 73,62:PRINT ;LS%:GCOL4,0
  530 R%=NEX%:X%=8:Z%=30:PROC_PIECE:PROC_DISP
  540 R%=NOW%:PROC_PIECE
  550 X%=44:Z%=56
  560 ENDPROC
  570 DEFPROC_DISP                                           //Displays the current piece at location X,Z
  580 RECTANGLE FILL D%+X%,I%+Z%,3
  590 RECTANGLE FILL E%+X%,J%+Z%,3
  600 RECTANGLE FILL F%+X%,K%+Z%,3
  610 RECTANGLE FILL G%+X%,L%+Z%,3
  620 ENDPROC
  630 DEFPROC_HIT                                              //Detects whether the current piece is hitting anything
  640 HIT%= (POINT(D%+X%,I%+Z%)=0) OR (POINT(E%+X%,J%+Z%)=0) OR (POINT(F%+X%,K%+Z%)=0) OR (POINT(G%+X%,L%+Z%)=0)
  650 ENDPROC
  660 DEFPROC_ROTR                              //Rotates the piece right
  670 B%=D%
  680 D%=-I%
  690 I%=B%
  700 B%=E%
  710 E%=-J%
  720 J%=B%
  730 B%=F%
  740 F%=-K%
  750 K%=B%
  760 B%=G%
  770 G%=-L%
  780 L%=B%
  790 ENDPROC
  800 DEFPROC_ROTL                   Rotates the piece left
  810 B%=-D%
  820 D%=I%
  830 I%=B%
  840 B%=-E%
  850 E%=J%
  860 J%=B%
  870 B%=-F%
  880 F%=K%
  890 K%=B%
  900 B%=-G%
  910 G%=L%
  920 L%=B%
  930 ENDPROC
  940 DEFPROC_PIECE                                                       //creates a new piece based on R%
  950 D%=0:E%=0:F%=0:G%=0:I%=0:J%=0:K%=0:L%=0
  960 IF R%=1 I%=4:K%=-4:L%=-8
  970 IF R%=2 D%=-4:F%=4:L%=4
  980 IF R%=3 D%=-4:I%=-4:J%=-4:L%=4
  990 IF R%=4 D%=-4:I%=4:J%=4:L%=-4
 1000 IF R%=5 D%=-4:G%=4:K%=4:L%=4
 1010 IF R%=6 D%=4:G%=-4:K%=4:L%=4
 1020 IF R%=7 F%=4:G%=4:J%=4:L%=4
 1030 ENDPROC
 1040 DEFPROC_LINE                                  //the beginning of the line checking algorithem
 1050 LIN%=-20
 1060 IF J%+Z%>LIN%:LIN%=J%+Z%
 1070 IF I%+Z%>LIN%:LIN%=I%+Z%
 1080 IF K%+Z%>LIN%:LIN%=K%+Z%
 1090 IF L%+Z%>LIN%:LIN%=L%+Z%
 1100 T%=0
 1110 FOR G%=LIN% TO LIN%-16 STEP -4
 1120   LIN%=G%:IF LIN%>0 PROC_CHECK
 1130 NEXT
 1140 S%=S%+(T%*5)^2
 1150 LS%=LS%+T%
 1160 LVL%=14.999-S%/500
 1170 ENDPROC
 1180 DEFPROC_CHECK                               //checks to see if the current line is full
 1190 B%=0
 1200 FOR F%=28 TO 64 STEP 4
 1210   IF 0=POINT(F%,LIN%) B%=B%+1
 1220 NEXT
 1230 IF B%=10 PROC_REM:T%=T%+1
 1240 ENDPROC
 1250 DEFPROC_REM                                                  //removes a full line and shifts the rest of the screen down
 1260 GCOL15:RECTANGLE FILL 28,LIN%,39,3:GCOL4,0
 1270 REPEAT
 1280   C%=0:LIN%=LIN%+4
 1290   FOR F%=28 TO 64 STEP 4
 1300     IF 0=POINT(F%,LIN%) C%=C%+1:RECTANGLE FILL F%,LIN%-4,3,7
 1310   NEXT
 1320 UNTIL  C%=0
 1330 ENDPROC
 1340 DEFPROC_END            //ends the program and re-sets all the variables
 1350 GCOL0
 1360 *FX4,0
 1370 *FX11,30
 1380 *FX12,10
 1390 CLG:CLS
 1400 *REFRESH ON
 1410 VDU 4

I use a lot of RECTANGLE FILL methods to draw things
« Last Edit: June 14, 2009, 07:55:49 pm by Builderboy »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBC Basic Tetris
« Reply #16 on: June 14, 2009, 07:43:14 pm »
for code boxes you use [ c o d e ] [ / c o d e ] (without the spaces)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: BBC Basic Tetris
« Reply #17 on: June 14, 2009, 07:56:04 pm »
Ah, thank you!  I changed it

Offline Ti-newb

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 180
  • Rating: +3/-0
    • View Profile
Re: BBC Basic Tetris
« Reply #18 on: June 16, 2009, 09:41:32 am »
Wow, Nice game. I didn't know what BBC Basic was.. and now i do.. (it looks very different then Ti-basic)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: BBC Basic Tetris
« Reply #19 on: August 16, 2009, 10:10:46 pm »
Hooray! Tetris has been featured on TiCalc!  Thanks to Duncan for the feature and the rest of the community too!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBC Basic Tetris
« Reply #20 on: August 16, 2009, 11:23:51 pm »
wow congrats for the feature! i really need to try bbc basic at one point. Hopefully this should be a good alternative to BASIC for arcade games or chapter-based RPGs

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: BBC Basic Tetris
« Reply #21 on: August 17, 2009, 12:40:22 am »
Yeah, you might be able to get around the file size limitation by hosting data in apvars or something.  But its really nice for making arcade games I've discovered :)

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
Re: BBC Basic Tetris
« Reply #22 on: August 17, 2009, 12:53:11 pm »
Congrats Builderboy!
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

Offline 3.1415926535

  • LV2 Member (Next: 40)
  • **
  • Posts: 34
  • Rating: +2/-0
    • View Profile
Re: BBC Basic Tetris
« Reply #23 on: August 17, 2009, 06:50:46 pm »
is BBC basic a realistic language for a beginner like me?

Offline TravisE

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 182
  • Rating: +33/-0
    • View Profile
    • ticalc.org
Re: BBC Basic Tetris
« Reply #24 on: August 17, 2009, 06:54:01 pm »
I think so. BASIC was meant to be an easy-to-learn language (since it stands for "Beginner's All-purpose Symbolic Instruction Code"). It's not the same as TI-BASIC, but BASIC variants are generally about as easy to learn.
ticalc.org staff member—http://www.ticalc.org/

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: BBC Basic Tetris
« Reply #25 on: August 17, 2009, 07:42:45 pm »
well BBC basic isn't as basic as basic... it gets harder and more in depth
/e

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: BBC Basic Tetris
« Reply #26 on: August 17, 2009, 09:05:58 pm »
is there a good tutorial on it?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6268
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: BBC Basic Tetris
« Reply #27 on: August 17, 2009, 09:25:07 pm »
not that I know of
/e

Offline miotatsu

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 332
  • Rating: +11/-1
    • View Profile
Re: BBC Basic Tetris
« Reply #28 on: August 17, 2009, 09:53:40 pm »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: BBC Basic Tetris
« Reply #29 on: August 17, 2009, 11:18:42 pm »
i think this language is harder than TI-BASIC because it date back in the early '80s, when almost everything was still done with assembly mostly