我正在用 Slick2d 用 Java 制作我的第一个游戏,并创建了一个类平面。(我也是java新手)
我不确定从我的类中的 Image 类扩展是否正确,或者我最好在我的类中使用公共 Image 属性(公共以便在项目的其余部分轻松访问它的方法)
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
public class Plane extends Image{
private float x;
private float y;
public Plane(String path, float x, float y) throws SlickException{
super(path);
this.x = x;
this.y = y;
}
public float getX(){
return x;
}
public float getY(){
return y;
}
public void move(float hip){
float rotation = this.getRotation();
x+= hip * Math.sin(Math.toRadians(rotation));
y-= hip * Math.cos(Math.toRadians(rotation));
}
}