麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

簡單的太陽系模型

2019-11-11 03:18:19
字體:
來源:轉載
供稿:網友

很早前學視頻的一個行星繞太陽轉的模型,沒事做著玩的不錯 這里寫圖片描述 主窗口

public class MyFrame extends Frame{public void lanchFrame(){ setSize(constant.GAME_WIDTH,constant.GAME_HEIGHT); setLocation(50, 50); setVisible(true); addWindowListener(new WindowAdapter(){ @Override public void windowClosing(WindowEvent e) { //窗口關閉 System.exit(0); } }); new PaintThread().start();} /* * 線程類,控制元素 */class PaintThread extends Thread{ public void run(){ while(true){ repaint(); try { Thread.sleep(50); } catch (InterruptedException e) { // TODO Auto-generated catch block e.PRintStackTrace(); } } } }}

主要天體及行星的布置

public class Planes extends Star{ double longAxis; //長軸 double shortAxis; //短軸 double speed; double degree; Star center; boolean satlittle; public void draw(Graphics g){ super.draw(g); drawTrace(g); move(); if(!satlittle){ drawTrace(g); } } public void move(){ x=center.x+center.width/2+longAxis*Math.cos(degree); y=center.y+center.heigth/2+shortAxis*Math.sin(degree); degree+=speed;} public void drawTrace(Graphics g){ int _x,_y,_width,_height; _width=(int) (longAxis*2); _height=(int) (shortAxis*2); _x=(int) ((center.x+center.width/2)-longAxis); _y=(int) ((center.y+center.heigth/2)-shortAxis); Color c=g.getColor(); g.setColor(Color.blue); g.drawOval((int)_x, (int)_y, (int)_width, (int)_height); g.setColor(c); } public Planes(Star center,String imgpath, double longAxis, double shortAxis, double speed) { this.center=center; this.x=center.x+longAxis; this.y=center.y; this.img=Gameutil.getImage(imgpath); this.width=img.getWidth(null); this.heigth=img.getHeight(null); this.longAxis = longAxis; this.shortAxis = shortAxis; this.speed = speed; } public Planes(Star center,String imgpath, double longAxis, double shortAxis, double speed,boolean satlittle) { this(center, imgpath, longAxis, shortAxis, speed); this.satlittle=satlittle; } public Planes(Image img,double x,double y){ super(img,x,y); } public Planes(String imgpath,double x,double y){ super(imgpath, x, y); }}package cn.hfz.uil;import java.awt.Graphics;import java.awt.Image;import cn.hfz.solor.Gameutil;public class Star { Image img; double x,y; int width,heigth; public void draw(Graphics g){ g.drawImage(img, (int)x, (int)y,null); } public Star(){} public Star(Image img,double x,double y){ this.img=img; this.x=x; this.y=y; this.width=img.getWidth(null); this.heigth=img.getHeight(null); } //封裝 public Star(String imgpath,double x,double y){ this(Gameutil.getImage(imgpath),x,y); }}

方位,圖片

package cn.hfz.uil;import java.awt.Graphics;import java.awt.Image;import cn.hfz.solor.Gameutil;import cn.hfz.solor.MyFrame;public class GameSolor extends MyFrame { Image backg=Gameutil.getImage("img/sky.gif"); Star sun=new Star("img/sun.gif", 350, 300); Planes earth=new Planes(sun, "img/earth.gif", 150, 100,0.06); Planes moon=new Planes(earth, "img/moon.gif", 30, 20,0.05,true); Planes Mars=new Planes(sun, "img/Mars.gif", 200, 130,0.05); Planes shuixin=new Planes(sun, "img/水星.gif",60 ,50 , 0.08); Planes jinxin=new Planes(sun, "img/金星.gif", 100, 60,0.07); Planes Muxin=new Planes(sun, "img/木星.gif",220 , 155, 0.04); Planes Tuxin=new Planes(sun, "img/土星.gif", 250, 170, 0.035); Planes Tianwx=new Planes(sun, "img/天王星.gif", 280, 190, 0.03); Planes Haiwx=new Planes(sun, "img/海王星.gif", 310, 210, 0.025); public void paint(Graphics g){ g.drawImage(backg,0, 0, null); sun.draw(g); earth.draw(g); Mars.draw(g); moon.draw(g); shuixin.draw(g); jinxin.draw(g); Muxin.draw(g); Tuxin.draw(g); Tianwx.draw(g); Haiwx.draw(g); } public static void main(String[] args){ new GameSolor().lanchFrame(); }}

程序打包已上傳,如下:

http://download.csdn.net/detail/t1012665655/9749752


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲欧美国产精品va在线观看 | 国产精品麻豆一区二区三区 | 美女一级视频 | 久久色在线 | 99r国产精品 | 99亚洲国产精品 | 国产88久久久国产精品免费二区 | 国产精品啪一品二区三区粉嫩 | 中文字幕亚洲视频 | 性明星video另类hd | 欧美日韩在线视频一区 | 一本一本久久a久久精品综合小说 | 欧美成人亚洲 | 国产免费资源 | 亚洲精品在线观看网站 | 国产剧情v888av | 黄色大片在线免费观看 | 国产一区在线免费 | 欧美极品欧美精品欧美视频 | 精品国产一区二区三区久久久蜜月 | 国产精品野外av久久久 | 亚洲综合色视频在线观看 | 久久久久久久久久美女 | 成人免费网站在线观看 | 毛片免费观看视频 | 日韩黄站| 久久6国产| 爽毛片| 中国字幕av | 日韩黄色一级视频 | 叶子楣成人爽a毛片免费啪啪 | 国产亚洲精品综合一区91 | 美女露100%无遮挡 | 欧美日韩一 | 高清视频91 | 亚洲资源在线 | 欧美一级高潮片免费的 | 久草在线综合 | 毛片在哪看 | 极品一级片 | 羞羞视频免费视频欧美 |