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

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

簡單的太陽系模型

2019-11-11 01:30:29
字體:
來源:轉載
供稿:網友

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

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 内地av在线 | 美女一级视频 | 欧日一级片 | 人禽l交免费视频观看 视频 | av免播放| 久久亚洲精品久久国产一区二区 | 黄色毛片免费看 | 在线免费小视频 | 在线中文字幕不卡 | 久草在线视频免费播放 | 成人性视频欧美一区二区三区 | 国产亚洲精品yxsp | 97视频| 亚洲免费观看视频 | 成人男女啪啪免费观看网站四虎 | 手机免费看一级片 | a免费看| 日韩视频高清 | 久草在线观看首页 | 一区二区免费 | 亚洲第一成人在线 | 久久久国产一区二区三区 | 一级做受大片免费视频 | 精品久久www | 中文字幕电影免费播放 | 久草视频免费 | 激情在线视频 | 精品999www| 日日操夜夜透 | 久久久久久免费免费 | 日本aaaa片毛片免费观看视频 | 毛片在线免费 | 精品久久久久久综合日本 | 一级看片免费视频 | 国产一级免费不卡 | 91毛片网站| 欧美 日韩 三区 | 亚洲午夜久久久久 | 一级做a爱片久久毛片a高清 | 狠狠干天天操 | chinese18 xxxx videos |