package cn.xia.solar;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import cn.xia.util.GameUtil;
public class Planet extends Star{
//除了图片坐标 行星沿着某个椭圆运行:长轴,短轴,速度,角度; 绕着某个Star.
double longAxis;
double shortAxis;
double speed;
double degree;
Star center;
boolean satellite;
public Planet(Star center,String imgpath, double longAxis, double shortAxis, double speed,boolean satellite) {
this(center, imgpath, longAxis, shortAxis, speed);
this.satellite = satellite;
}
public Planet(Star center,String imgpath, double longAxis, double shortAxis, double speed) {
super(GameUtil.getImage(imgpath));
this.center = center;
this.x=center.x+longAxis;
this.y=center.y;
this.longAxis = longAxis;
this.shortAxis = shortAxis;
this.speed = speed;
this.width = img.getWidth(null);
this.height = img.getHeight(null);
}
public void draw(Graphics g){
//g.drawImage(img,(int)x,(int)y,null);
super.draw(g);
//沿着椭圆轨迹飞行
if(!satellite){
//drawTrace(g);
}
move();
}
public void move(){
x=(center.x+15) + longAxis*Math.cos(degree);
y=(center.y+15) + shortAxis*Math.sin(degree);
degree +=speed;
}
public void drawTrace(Graphics g){
double ovalX,ovalY,ovalWidth,ovalHeigth;
ovalWidth=longAxis*2;
ovalHeigth= shortAxis*2;
ovalX=center.x-longAxis+15;
ovalY=center.y-shortAxis+15;
Color c = g.getColor();
g.setColor(Color.blue);
g.drawOval((int)ovalX, (int)ovalY, (int)ovalWidth, (int)ovalHeigth);
g.setColor(c);
}
public Planet(String imgpath, double x, double y) {
super(imgpath, x, y);
}
public Planet(Image img, double x, double y) {
super(img, x, y);
}
}
最近下载更多
lczbossd LV1
2023年11月21日
qq1434100519 LV1
2023年11月1日
lx1216 LV1
2023年10月7日
微信网友_6575311013466112 LV1
2023年7月24日
xiaokang1 LV10
2023年6月3日
azuldsf LV1
2023年2月20日
1151062880 LV1
2022年11月11日
liuhuaxiang LV1
2022年10月1日
wanshubin LV1
2022年10月1日
微信网友_6134148373270528 LV1
2022年9月15日
最近浏览更多
蜡笔小赵
2024年11月1日
暂无贡献等级
fanjiesen
2024年10月25日
暂无贡献等级
aaallll
2024年6月6日
暂无贡献等级
suishuaike LV8
2024年5月9日
微信网友_6912871225888768 LV1
2024年3月18日
lczbossd LV1
2023年11月21日
qq1434100519 LV1
2023年11月1日
EFWAGGFAWGR
2023年10月19日
暂无贡献等级
lx1216 LV1
2023年10月7日
微信网友_6575311013466112 LV1
2023年7月24日

