📄 shot3d.java
字号:
import java.applet.*;
import java.awt.*;
class Shot3D extends Object3D
{
static final int SHOT_SPEED = 18;
static double Object[] = { 0, -10, 0,
0, 10, 0};
static int Lines[] = { 0,1};
public Shot3D(double x, double y, double z, int xr, int yr, int zr)
{
Name = "Shot3D";
XPos = x;
YPos = y;
ZPos = z;
XRot = xr;
YRot = yr;
ZRot = zr;
VertNum = Object.length / 3;
LineNum = Lines.length / 2;
Vertices = new Vector3D[VertNum];
Points = new Point2D[VertNum];
for (int i=0; i<VertNum; i++)
{
Points[i] = new Point2D();
Vertices[i] = new Vector3D();
Vertices[i].x = Object[i*3+X];
Vertices[i].y = Object[i*3+Y];
Vertices[i].z = Object[i*3+Z];
}
Visible = true;
WebWar.LaserSfx.play();
}
public void Draw(Graphics g, Matrix3D CameraMatrix)
{
Matrix3D MyMatrix = new Matrix3D();
MyMatrix.RotateZ(ZRot);
MyMatrix.RotateX(XRot);
MyMatrix.RotateY(YRot);
MyMatrix.Scale(XScale,YScale,ZScale);
MyMatrix.Shear(XShear,YShear);
MyMatrix.Translate(XPos,YPos,ZPos);
MyMatrix.Merge(CameraMatrix.GetMatrix());
for (int i=0; i<VertNum; i++)
{
MyMatrix.Transform(Vertices[i]);
Points[i] = Point2D.Projection(Vertices[i]);
}
for (int i=0; i<LineNum; i++)
{
g.setColor(new Color(255,0,0));
g.drawLine(Points[Lines[i*2]].x,Points[Lines[i*2]].y,Points[Lines[i*2+1]].x,Points[Lines[i*2+1]].y);
}
}
public boolean Handler()
{
ZPos += SHOT_SPEED;
if (ZPos >= 1000)
{
Ship3D.LaserCount--;
return false;
}
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -