Gwbasictetris
Gwbasictetris
999 WIDTH 80: COLOR 7,0: PRINT "GAME OVER" : KEY ON: END
Written in July 2010.
110 REM Flush input buffer: WHILE INKEY$<>"":WEND P.S. The colors in this code are hints for me in directing
130 c=colorwhenmove: GOSUB 700 'Draw the current block the Youtube video. – Joel Yliluoma
140 ' Wait for input before dropping the block a bit
150 ti!=TIMER + 0.5 ’ *** TESTING BARRIER
160 WHILE TIMER < ti! 400 ' Make full lines empty
250 WEND 'done 410 FOR y=1 TO 23
300 'Move down after timer elapsed 420 x=1: WHILE x<=10 AND area(x,y)>0: x=x+1: WEND
310 mx=curx: my=cury: mr=currotate 421 empty=x>10
320 cury=cury+1: GOSUB 600 ' Try moving down 430 IF empty THEN c=0: FOR x=1 TO 10: GOSUB 900: SOUND
330 IF collided=0 THEN 150 ' Loop until collision 40+RND*200,.1:NEXT
340 ' The block hit the ground. 440 NEXT
350 c=colorwhendone: GOSUB 700 ' Draw at final color 81 DIM emptyline(23)
499 GOTO 100 ' Generate a new block 405 emptycount=0
422 emptyline(y) = empty: IF empty THEN
600 ' Try moving to a given direction emptycount=emptycount+1
601 ' Params: curx,cury,curblock,currotate: Suggested new position 423 NEXT
602 ' Params: mx,my,mr: Current position 424 IF emptycount=0 THEN 499
603 ' Output: collided=1 -> No move (curx,.. reset to mx,..) 425 empty$ = ".." + MID$("SINGLEDOUBLETRIPLETETRIS",
604 ' collided=0 -> Moved emptycount*6-5, 6) + ".."
605 ' In either case, mx,my,mr will be overwritten. 426 DEF FNempty$(x) = MID$(empty$,x,1)
610 GOSUB 800 'Test move 427 FOR y=1 TO 23
620 SWAP mx,curx:SWAP my,cury:SWAP mr,currotate 428 empty = emptyline(y)
630 IF collided THEN RETURN 'No move 445 DEF FNempty$(x) = "."
640 ' No obstacle for moving block
650 c=0: GOSUB 700 ' Undraw at old location 450 ' Drop non-empty lines that are above empty lines
660 SWAP mx,curx:SWAP my,cury:SWAP mr,currotate 451 y=23 'Target of next non-empty line = bottom
670 c=colorwhenmove: GOTO 700 ' Draw at new location 460 FOR source=23 TO 1 STEP -1
120 dropping=0 ’ *** TESTING BARRIER 465 x=1: WHILE x<=10 AND area(x,source)=0: x=x+1: WEND
170 k$ = INKEY$ 470 empty = x>10
180 mx=curx: my=cury: mr=currotate 480 IF y<>source THEN FOR x=1 TO 10: c=area(x,source): GOSUB 900: NEXT
190 IF k$="w" THEN currotate=(currotate+1)AND 3: dropping=0: GOSUB 600 490 IF NOT empty THEN y=y-1
200 IF k$="a" THEN curx=curx-1: dropping=0: GOSUB 600 495 NEXT
210 IF k$="d" THEN curx=curx+1: dropping=0: GOSUB 600 496 ' Clear the top in case it was not cleared yet
220 IF k$="q" THEN GOTO 999 ' Gameover if request quit 497 c=0
230 IF k$="s" OR dropping=1 THEN 300 'Try moving down 498 WHILE y>1: FOR x=1 TO 10: GOSUB 900: NEXT: y=y-1: WEND
240 IF k$=" " THEN dropping=1 462 SOUND 30+source*40,.5