只提供参考源码
import java.awt.*;
import java.applet.Applet;
public class Blocks extends Applet implements Runnable
{
Dimension d;
Font largefont= new Font("Helvetica", Font.BOLD, 28);
Font smallfont= new Font("Helvetica", Font.BOLD, 10);
Color textcolor1=new Color(96,128,255);
Color textcolor2=new Color(255,160,64);
FontMetrics fmsmall, fmlarge;
Graphics goff;
Image ii;
Threadthethread;
boolean ingame=false;
final short xblocks=10;
final short yblocks=20;
final int blocksize=16;
final int width=xblocks*blocksize;
final int height=yblocks*blocksize;
short[][] screendata;
final short maxcolors=6;
Color[] blocks;
final int barwidth=8;
final Color barcolor=new Color(128,255,64);
final Color background=new Color(0,0,0);
int score;
short emptyline;
int objectx, objecty;
int objectx;
short objecttype;
short objectcolor;
int objectrotation;
int objectrotationd=0;
short objectptr;
short checkptr;
final short itemcount=7;
final short itemrotlen=8;
final short itemlen=itemrotlen*4;
short count;
final short maxcount=5;
short curcount;
boolean fast=false;
final short screendelay=40;
short screencount=40;
boolean showtitle=true;
int items[]={
0,0, -1,0, 0,-1, -1,-1, //四方形,正常状态
0,0, -1,0, 0,1, -1,1, //被旋转90度
0,0, 1,0, 0,1, 1,1,
0,0, 1,0, 0,-1, 1,-1,
0,0, 0,-1, 0,-2, 0,-3,
0,0, -1,0, -2,0, -3,0,
0,0, 0,1, 0,2, 0,3,
0,0, 1,0, 2,0, 3,0,
0,0, 1,0, 0,-1, -1,-1,
0,0, 0,-1, -1,0, -1,1,
0,0, -1,0, 0,1, 1,1,
0,0, 0,1, 1,0, 1,-1,
0,0, -1,0, 0,-1, 1,-1,
0,0, 0,1, -1,0, -1,-1,
0,0, 1,0, 0,1, -1,1,
0,0, 0,-1, 1,0, 1,1,
0,0, 1,0, -1,0, 0,-1,
0,0, 0,1, 0,-1, -1,0,
0,0, 0,1, -1,0, 1,0,
0,0, 1,0, 0,-1, 0,1,
0,0, 0,-1, 1,-1, 0,1,
0,0, -1,0, -1,-1, 1,0,
0,0, -1,1, 0,1, 0,-1,
0,0, -1,0, 1,0, 1,1,
0,0, 0,1, 0,-1, -1,-1,
0,0, 1,0, -1,0, -1,1,
0,0, 0,-1, 0,1, 1,1,
0,0, -1,0, 1,0, 1,-1,
};
int checks[]={
-1,1, 0,1, -1,1, 0,1,
-1,2, 0,2, -1,2, 0,2,
0,2, 1,2, 0,2, 1,2,
0,1, 1,1, 0,1, 1,1,
0,1, 0,1, 0,1, 0,1,
0,1, -1,1, -2,1, -3,1,
0,4, 0,4, 0,4, 0,4,
0,1, 1,1, 2,1, 3,1,
0,1, -1,0, 1,1, 0,1,
0,1, -1,2, 0,1, -1,2,
0,2, 1,2, -1,2, 0,2,
0,2, 1,1, 0,2, 1,1,
-1,1, 0,1, 1,0, 1,0,
-1,1, 0,2, 0,2, -1,1,
-1,2, 0,2, 1,1, 1,1,
0,1, 1,2, 0,1, 1,2,
-1,1, 0,1, 1,1