[java]代码库
package com.jackie.solarsystem.projects;
import java.awt.Graphics;
import java.awt.Image;
import com.jackie.solarsystem.entities.Planet;
import com.jackie.solarsystem.entities.Star;
import com.jackie.solarsystem.utils.Constant;
import com.jackie.solarsystem.utils.SolarSystemFrame;
import com.jackie.solarsystem.utils.SolarSystemUtils;
/**
* 太阳系运行程序入口界面
* @author Administrator
*
*/
public class SolarMainWin extends SolarSystemFrame{
private static final long serialVersionUID = 1L;
Image bg = SolarSystemUtils.getImage("images/solar-bg.jpg");
Star sun = new Star("images/sun.jpg", Constant.FRAME_WIDTH/2-15, Constant.FRAME_HEIGHT/2-15);
Planet mercury = new Planet(sun, "images/Mercury.jpg", 40, 20, 0.1);
Planet venus = new Planet(sun, "images/Venus.jpg", 70, 40, 0.2);
Planet earth = new Planet(sun, "images/Earth.jpg", 100, 50, 0.3);
Planet mars = new Planet(sun, "images/Mars.jpg", 130, 80, 0.2);
Planet jupiter = new Planet(sun, "images/Jupiter.jpg", 170, 100, 0.4);
Planet saturn = new Planet(sun, "images/Saturn.jpg", 260, 150, 0.4);
Planet uranus = new Planet(sun, "images/Uranus.jpg", 350, 190, 0.1);
Planet neptune = new Planet(sun, "images/Neptune.jpg", 500, 250, 0.3);
Planet moon = new Planet(earth, "images/moon.jpg", 100, 40, 0.5,true);
public void paint(Graphics g){
g.drawImage(bg, Constant.FRAME_LOCATION_X, Constant.FRAME_LOCATION_Y, null);
sun.drawStar(g);
mercury.draw(g);
venus.draw(g);
earth.draw(g);
mars.draw(g);
jupiter.draw(g);
saturn.draw(g);
uranus.draw(g);
neptune.draw(g);
moon.draw(g);
}
public static void main(String[] args) {
new SolarMainWin().launchFrame();
}
}
[代码运行效果截图]
[源代码打包下载]
初级程序员
by: 简明 发表于:2017-11-27 16:36:58 顶(0) | 踩(0) 回复
谢谢分享,好好学习
回复评论