import java.awt.*;
import java.applet.Applet;
public final class rubik extends Applet
{
int i;
int j;
int k;
int n;
int o;
int p;
int q;
int lastX;
int lastY;
int dx;
int dy;
int rectX[];
int rectY[];
Color colList[];
Color bgcolor;
final double sideVec[] = { 0.0, 0.0, 1.0, 0.0, 0.0, -1, 0.0, -1, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, -1, 0.0, 0.0 };
final double corners[] = { -1, -1, -1, 1.0, -1, -1, 1.0, 1.0, -1, -1, 1.0, -1, -1, -1, 1.0, 1.0, -1,
1.0, 1.0, 1.0, 1.0, -1, 1.0, 1.0 };
double topCorners[];
double botCorners[];
final int sides[] = { 4, 5, 6, 7, 3, 2, 1, 0, 0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6, 0, 4, 7, 3 };
final int nextSide[] = { 2, 3, 4, 5, 4, 3, 2, 5, 1, 3, 0, 5, 1, 4, 0, 2, 1, 5, 0, 3, 2, 0, 4, 1 };
final int mainBlocks[] = { 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3 };
final int twistDir[] = { -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, 1, -1, 1, -1, 1 };
final int colDir[] = { -1, -1, 1, -1, 1, -1 };
final int circleOrder[] = { 0, 1, 2, 5, 8, 7, 6, 3 };
int topBlocks[];
int botBlocks[];
int sideCols[];
int sideW;
int sideH;
int dragReg;
int twistSide;
int nearSide[];
int buffer[];
double dragCorn[];
double dragDir[];
double eye[] = { 0.3651, 0.1826, -0.9129 };
double eX[] = { 0.9309, -0.0716, 0.3581 };
double eY[];
double Teye[];
double TeX[];
double TeY[];
double light[];
double temp[] = { 0.0, 0.0, 0.0 };
double temp2[] = { 0.0, 0.0, 0.0 };
double newCoord[];
double sx;
double sy;
double sdxh;
double sdyh;
double sdxv;
double sdyv;
double d;
double t1;
double t2;
double t3;
double t4;
double t5;
double t6;
double phi;
double phibase;
double Cphi;
double Sphi;
double currDragDir[];
boolean naturalState;
boolean twisting;
boolean OKtoDrag;
double local0;
Math m;
Graphics offGraphics;
Image offImage;
public void init()
{
offImage = createImage(120, 120);
offGraphics = Graphics();
rectX = new int[4];
rectY = new int[4];
newCoord = new double[16];
dragDir = new double[24];
dragCorn = new double[96];
topCorners = new double[24];
botCorners = new double[24];
topBlocks = new int[24];入门的java游戏小程序
botBlocks = new int[24];
buffer = new int[12];
nearSide = new int[12];
light = new double[3];
Teye = new double[3];
TeX = new double[3];
TeY = new double[3];
currDragDir = new double[2];
eY = new double[3];
vecProd(eye, 0, eX, 0, eY, 0);
normalize(eY, 0);
colList = new Color[120];
for (i = 0; i < 20; i++)
{
colList[i] = new Color(103 + i * 8, 103 + i * 8, 103 + i * 8);
colList[i + 20] = new Color(i * 6, i * 6, 84 + i * 9);
colList[i + 40] = new Color(84 + i * 9, i * 5, i * 5);
colList[i + 60] = new Color(i * 6, 84 + i * 9, i * 6);
colList[i + 80] = new Color(84 + i * 9, 84 + i * 9, i * 6);
colList[i + 100] = new Color(84 + i * 9, 55 + i * 8, i * 3);
}
sideCols = new int[54];
for (i = 0; i < 54; i++)
sideCols[i] = i / 9;
bgcolor = findBGColor();
resize(125, 125);
repaint();
}
public Color findBGColor()
{
Color color;
String string2 = "0123456789abcdef";
int an[] = new int[6];
String string1 = getParameter("bgcolor");
if (string1 != null && string1.length() == 6)
{
for (i = 0; i < 6; i++)
for (j = 0; j < 16; j++)
if (string1.charAt(i) == string2.charAt(j))
an[i] = j;
color = new Color(an[0] * 16 + an[1], an[2] * 16 + an[3], an[4] * 16 + an[5]);
}
else
color = Color.lightGray;
return color;
}
public double scalProd(double ad1[], int i, double ad2[], int j)
{
return ad1[i] * ad2[j] + ad1[i + 1] * ad2[j + 1] + ad1[i + 2] * ad2[j + 2];
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论