当前位置: 首页 > news >正文

新疆建设兵团门户网站竞价代运营

新疆建设兵团门户网站,竞价代运营,浙江seo技术培训,临沂做网站首选第一步是创建项目 项目名自拟 第二步创建个包名 来规范class 再创建一个包 来存储照片 如下: package game; import java.awt.*; import javax.swing.*; import javax.imageio.ImageIO;public class Bird {Image image;int x,y;int width,height;int size;doubl…

第一步是创建项目 项目名自拟

第二步创建个包名 来规范class

再创建一个包  来存储照片

如下:

package game;
import java.awt.*;
import javax.swing.*;
import javax.imageio.ImageIO;public class Bird {Image image;int x,y;int width,height;int size;double g;double t;double v0;double speed;double s;double alpha;//֡Image[] images;int index;public Bird() throws Exception{image=new ImageIcon("source/0.png").getImage();width = image.getWidth(null);height = image.getHeight(null);x=132;y=280;size=40;g=4;v0=20;t=0.25;speed=v0;s=0;alpha=0;images=new Image[8];for(int i=0;i<8;i++){images[i]=new ImageIcon("source/"+i+".png").getImage();}index=0;}public void fly(){index++;image=images[(index/12)%8];}public void step(){double v0=speed;s=v0*t+g*t*t/2;y=y-(int)s;double v=v0-g*t;speed =v;alpha=Math.atan(s/8);}public void flappy(){speed=v0;}public boolean hit(Ground ground){boolean hit =y+size/2>ground.y;if(hit){y=ground.y-size/2;alpha=Math.PI/2;}return hit;}public boolean hit(Column column){if(x>column.x-column.width/2-size/2&&x<column.x+column.width/2+size/2){if(y>column.y-column.gap/2+size/2&&y<column.y+column.gap/2-size/2) return false;return true;}return false;}
}
package game;import javax.imageio.ImageIO;
import java.util.*;import javax.swing.*;import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import javax.imageio.*;
import java.awt.*;public class BirdGame extends JPanel {Image background;Image startImage;Image overImage;Ground ground;//����Column column1,column2;Bird bird;int score;int state;//״̬//״̬����public static final int START=0;public static final int RUNNING=1;public static final int GAME_OVER=2;public BirdGame() throws Exception{background = new ImageIcon("./source/bg.png").getImage();startImage = new ImageIcon("./source/start.png").getImage();overImage=new ImageIcon("./source/gameover.png").getImage();//״̬ground=new Ground();column1=new Column(1);column2=new Column(2);bird=new Bird();score=0;state=0;}public void paint(Graphics g){g.drawImage(background, 0, 0,null);g.drawImage(ground.image, ground.x, ground.y, null);g.drawImage(column1.image,column1.x-column1.width/2,column1.y-column1.height/2,null);g.drawImage(column2.image,column2.x-column2.width/2,column2.y-column2.height/2,null);Graphics2D g2=(Graphics2D) g;g2.rotate(-bird.alpha,bird.x,bird.y);g.drawImage(bird.image,bird.x-bird.width/2,bird.y-bird.height/2,null);g2.rotate(bird.alpha,bird.x,bird.y);Font f=new Font(Font.SANS_SERIF,Font.BOLD,40);g.setFont(f);g.drawString(""+score, 40, 60);g.setColor(Color.WHITE);g.drawString(""+score,40-3, 60-3);switch(state){case START:g.drawImage(startImage, 0, 0, null);break;case GAME_OVER:g.drawImage(overImage, 0, 0, null);break;}}public void action() throws Exception{MouseListener l=new MouseAdapter(){public void mousePressed(MouseEvent e){try {switch(state) {case START://״̬state=RUNNING;break;case RUNNING:bird.flappy();break;case GAME_OVER:column1=new Column(1);column2=new Column(2);bird=new Bird();score=0;state=START;break;}}catch (Exception ex){ex.printStackTrace();}}};addMouseListener(l);while(true){switch(state){case START:bird.fly();ground.step();break;case RUNNING:ground.step();column1.step();column2.step();bird.fly();bird.step();score++;//if(bird.hit(ground)||bird.hit(column1)||bird.hit(column2)){state=GAME_OVER;}break;}	Thread.sleep(1000/60);repaint();}}public static void main(String[] args) throws Exception{JFrame frame=new JFrame();BirdGame game=new BirdGame();frame.add(game);frame.setSize(440,670);frame.setLocationRelativeTo(null);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setVisible(true);game.action();}}
package game;import java.util.*;
import java.awt.*;import javax.imageio.ImageIO;
import javax.swing.*;public class Column {Image image;int x,y;int width,height;int gap;int distance;Random random =new Random();public Column(int n) throws Exception{image=new ImageIcon("source/column.png").getImage();width=image.getWidth(null);height=image.getHeight(null);gap=144;distance=245;x=550+(n-1)*distance;y=random.nextInt(218)+132;}public void step(){x-=4;if(x<= -width/2){x=distance*2-width/2;y=random.nextInt(218);}}
}
package game;import javax.swing.*;
import java.awt.*;public class Ground {Image image;int x,y;int width,height;public Ground() throws Exception{image =new ImageIcon("source/ground.png").getImage();width=image.getWidth(null);height=image.getHeight(null);x=0;y=500;}public void step(){x-=4;if(x<=-109){x=0;}}}

http://www.hrbkazy.com/news/22652.html

相关文章:

  • 做网站销售好吗企业网站注册
  • 岳阳做网站seo网络营销技术
  • 寄生虫网站排名代做长沙官网seo分析
  • jsp与网站开发期末试题广东东莞最新疫情
  • 百度收录网站方法软文兼职
  • 厦门网站排名优化费用抖音黑科技引流推广神器
  • bootstrap网站案例优化大师免费下载
  • 盈润企业网站管理系统如何进行网站推广
  • 建设银行造价咨询中心网站线上推广网络公司
  • 网站后台怎么修改文字lol今日赛事直播
  • 网站制作的公司搜索引擎营销的实现方法有哪些
  • 一个网站的建设需要哪些流程最近一周新闻热点回顾
  • 徐州手机网站制作刷外链
  • pc网站手机版开发电商还有发展前景吗
  • 为什么WORDPRESS后台很卡网站优化快速排名软件
  • 做网站在哪里可以找到高清壁纸指数分布的分布函数
  • 常见的独立站建站工具有哪些如何注册自己的网站
  • 做同业业务一般关注哪些网站合肥关键词排名工具
  • 深圳网页设计兴田德润实惠兰州seo实战优化
  • 做代理网站用什么软件营销策划与运营
  • Wordpress建站用什么系统贴吧aso优化贴吧
  • 网站制作常见问题 图片版权百度销售平台怎样联系
  • 如何做网页游戏网站百度上海推广优化公司
  • wordpress 白色百度seo软件是做什么的
  • 影视广告片拍摄厂家seo最新快速排名
  • 云南网站设计平台站长之家查询域名
  • 共享办公wework西安做推广优化的公司
  • 做婚礼邀请函网站qq群引流推广平台免费
  • 潍坊网站建设制作搜索引擎google
  • 个人电脑做网站关键词排名怎么做上首页