资源描述:
《基于java雷电游戏项目报告毕业论文》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、《Java程序设计》实验报告年级、专业、班级2011级网络1班2011级网络1班2011级网络1班姓名实验题目编程实现雷电游戏实验时间2013.10.22-2013.11.6实验地点主教0410实验成绩实验性质□验证性□设计性■综合性教师评价:□算法/实验过程正确;□源程序/实验内容提交□程序结构/实验步骤合理;□实验结果正确;□语法、语义正确;□报告规范;其他:评价教师签名:一、实验目的利用JavaGUI、JavaGraphics和多线程技术,编写实现飞行射击游戏——雷电。二、实验项目内容1、根据项目任务书,形成完整的需求分析。2、根据需求,完成详细的设计。3、基于Java编程
2、实现。三、实验过程或算法(源程序)关键代码:Boss.javapackagecqu;publicclassBossextendsFlyingObject{publicBoss(intx){super(x,0,250,100,Resources.bossPNG);//TODOAuto-generatedconstructorstub}@Overridepublicvoidmove(longtime){//TODO自动生成的方法存根}publicBulletfire(){intx=(int)(Math.random()*350);inty=100;Bulletb=newBullet(
3、x,y,true);returnb;}}Bullet.javapackagecqu;publicclassBulletextendsFlyingObject{publicintxSpeed;publicBullet(intx,inty,booleanenemy){super(x,y,10,10,Resources.bulletPNG);this.enemy=enemy;xSpeed=0;}privatebooleanenemy;publicbooleanisEnemy(){returnenemy;}@Overridepublicvoidmove(longtime){if(time
4、%40==0){if(enemy){y+=30;}else{y-=30;x+=xSpeed;}}}}CBullet.javapackagecqu;publicclassCBulletextendsFlyingObject{publicCBullet(intx){super(x,0,30,30,Resources.addPNG);}@Overridepublicvoidmove(longtime){if(time%160==0){y+=Math.random()*4+10;//x+=4-Math.random()*6;}}}Enemy.javapublicclassEnemyext
5、endsFlyingObject{publicEnemy(intx,inty){super(x,y,40,40,Resources.enemyPNG);}publicBulletfire(){intx=this.x+12;inty=this.y+this.height;Bulletb=newBullet(x,y,true);returnb;}@Overridepublicvoidmove(longtime){if(time%160==0){y+=Math.random()*4+10;//x+=4-Math.random()*6;}}}FlyObject.javapackagecq
6、u;importjava.awt.Graphics;importjava.awt.image.BufferedImage;abstractpublicclassFlyingObject{protectedintx;protectedinty;protectedintwidth;protectedintheight;privateBufferedImageimage;publicFlyingObject(intx,inty,intwidth,intheight,BufferedImageimage){super();this.x=x;this.y=y;this.width=widt
7、h;this.height=height;this.image=image;}abstractpublicvoidmove(longtime);publicvoiddraw(Graphicsg){g.drawImage(image,x,y,width,height,null);}publicintgetWidth(){returnwidth;}publicvoidsetWidth(intwidth){this.width=width;}publicintgetHeight(){r