我正在制作我的第一个游戏(小行星),直到现在我一直使用多边形作为太空飞船但是我想使用我画的图像。我如何拍摄我所拥有的并绘制图像,使其表现得像多边形一样?
我的抽奖方法:
public void draw(Graphics2D g){
AffineTransform at = g.getTransform();
g.translate(position.x, position.y);
double rot = direction.angle() + Math.PI / 2;
g.rotate(rot);
g.scale(DRAWING_SCALE, DRAWING_SCALE);
g.setColor(COLOR);
g.fillPolygon(XP, YP, XP.length);
if (thrusting) {
g.setColor(Color.orange);
g.fillPolygon(XPTHRUST, YPTHRUST, XPTHRUST.length);
}
g.setTransform(at);
}
我的坐标数组:
public int[] XP = {0,1,0,-1}; //sets the position of the ship
public int[] YP = {1,-1,0,-1};
public int[] XPTHRUST = {0,1,0,-1}; //sets position of thrust
public int[] YPTHRUST = {-3,-1,0,-1};