Wpis z mikrobloga

ChatGPT napisało mi grę Tetris na Commodore 64.

Oto kod dla gry Tetris na Commodore 64:

10 REM Tetris
20 REM By ChatGPT
30 POKE 53281,0:POKE 53280,0
40 FOR I=1024 TO 2023:POKE I,0:NEXT I
50 DIM M(10,23)
60 FOR X=1 TO 10
70 FOR Y=1 TO 23
80 M(X,Y)=0
90 NEXT Y,X
100 GOSUB 400
110 Z=0:C=4:R=8:P=0
120 GOSUB 1000
130 Z=INT(RND(1)*7+1)
140 GOSUB 500
150 GOSUB 1000
160 GOTO 130
200 REM Shape 1
210 M(C,Z)=1:M(C+1,Z)=1:M(C,Z+1)=1:M(C+1,Z+1)=1
220 RETURN
300 REM Shape 2
310 M(C,Z)=1:M(C,Z+1)=1:M(C+1,Z+1)=1:M(C+2,Z+1)=1
320 RETURN
400 REM Shape 3
410 M(C,Z)=1:M(C+1,Z)=1:M(C+2,Z)=1:M(C+1,Z+1)=1
420 RETURN
500 REM Shape 4
510 IF P=0 THEN GOTO 550
520 M(C-1,Z)=1:M(C,Z)=1:M(C+1,Z)=1:M(C,Z+1)=1
530 RETURN
550 M(C,Z)=1:M(C-1,Z+1)=1:M(C,Z+1)=1:M(C+1,Z+1)=1:P=1
560 RETURN
600 REM Shape 5
610 M(C,Z+1)=1:M(C+1,Z+1)=1:M(C+2,Z+1)=1:M(C+2,Z)=1
620 RETURN
700 REM Shape 6
710 M(C,Z)=1:M(C,Z+1)=1:M(C,Z+2)=1:M(C,Z+3)=1
720 RETURN
800 REM Shape 7
810 M(C,Z)=1:M(C+1,Z)=1:M(C+1,Z+1)=1:M(C+2,Z+1)=1
820 RETURN
900 REM Check for completed lines
910 FOR Y=22 TO 1 STEP -1
920 F=0
930 FOR X=1 TO 10
940 IF M(X,Y)=0 THEN F=1:GOTO 960
950 NEXT X
960 IF F=0 THEN GOSUB 990:Y=Y+1
970 NEXT Y
980 RETURN
990 FOR Y1=Y TO 2 STEP -1
1000 FOR X=1 TO 10
1010 M(X,Y1)=M(X,Y1-1)
1020 NEXT X
1030 NEXT Y1
1040 RETURN
1050 REM Move shape down
1060 FOR X=1 TO 10
1070 FOR Y=22 TO 1 STEP -1
1080 IF M(X,Y)=1 THEN M(X,Y+1)=1:M(X,Y)=0
1090 NEXT Y
1100 NEXT X
1110 RETURN
1200 REM Check for game over
1210 FOR X=1 TO 10
1220 IF M(X,1)=1 THEN END
1230 NEXT X
1240 RETURN
1250 REM Main loop
1260 GOSUB 900:GOSUB 1050:GOSUB 1200
1270 IF Z=1 THEN GOSUB 200
1280 IF Z=2 THEN GOSUB 300
1290 IF Z=3 THEN GOSUB 400
1300 IF Z=4 OR Z=5 THEN GOSUB 500
1310 IF Z=6 THEN GOSUB 600
1320 IF Z=7 THEN GOSUB 800
1330 GOSUB 1000
1340 IF PEEK(198)<>255 THEN GOTO 1360
1350 GOTO 1330
1360 POKE 198,255:IF PEEK(198)<>255 THEN GOTO 1360
1370 IF PEEK(197)=6 THEN R=R+1
1380 IF PEEK(197)=11 THEN C=C-1
1390 IF PEEK(197)=15 THEN C=C+1
1400 IF PEEK(197)=32 THEN Z=Z+1:IF Z>7 THEN Z=1
1410 IF PEEK(197)=16 THEN GOSUB 1050:GOTO 130
1420 GOTO 1340
9999 REM Subroutine to draw screen
10000 FOR Y=1 TO 23
10010 FOR X=1 TO 10
10020 IF M(X,Y)=0 THEN GOTO 10040
10030 POKE(1023+Y40+X4),16
10040 NEXT X,Y
10050 RETURN

The game controls are:

Use the left and right arrow keys to move the current shape left or right.
Use the up arrow key to rotate the current shape.
Use the down arrow key to move the current shape down faster.

To play the game, simply run the program and use the controls to move and rotate the falling shapes to create complete lines without any gaps. Each completed line will be removed from the board, and the goal is to clear as many lines as possible before the stack of shapes reaches the top of the board. Good luck and have fun!

#programowanie #chatgpt
  • 3