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

广州的网站建设惠州seo推广外包

广州的网站建设,惠州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;double g;double t;…

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

第二步创建个包名 来规范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.hkea.cn/news/989990/

相关文章:

  • 深圳市工程建设交易服务中心网站软文什么意思
  • 大型网架加工厂成都网站建设方案优化
  • 导航网站的广告怎么做的千锋教育官方网
  • etc网站开发票网站制作软件免费下载
  • 上海seo网站设计2022十大网络营销案例
  • 还有做网站的必要吗网站运营推广方案
  • 企业营销型网站建设厂家品牌搜索引擎服务优化
  • 学校网站建设计划怎么成为百度推广代理商
  • 普陀网站开发培训学校seo快速优化
  • 建一个商城网站多少钱免费的网站推广软件
  • 手机网站解决方案看网站搜什么关键词
  • 顺企网江西网站建设宜昌今日头条新闻
  • 坪山网站建设行业现状网页设计与制作代码成品
  • 网站建设需求文档模板下载学大教育一对一收费价格表
  • 小型网站怎样优化百度首页官网
  • 网站开发与iso9001关系百度上做推广怎么做
  • wordpress怎么设置导航镇江seo
  • 番禺建设网站服务软文写作网站
  • 有哪些专做自然风景图片的网站石首seo排名
  • 移动网站虚拟主机seo 排名 优化
  • 专业网站建设课程网站推广优化方式
  • 适合站长做的网站信息流广告投放工作内容
  • 做健身网站步骤网站建设网络公司
  • 武汉整站seo数据上云网站关键词优化怎么做的
  • 网站尾部网络seo推广
  • 建设一个公司网站需要什么知识网站网络推广优化
  • 政府高度重视网站建设怎么做网络推广
  • 自己做的网站是怎么赚钱免费ip地址网站
  • 郑州市政府网站集约化建设计划企业seo排名外包
  • 什么网站可以免费做护师题企业网站管理系统源码