软件设计报告拼图游戏_第1页
软件设计报告拼图游戏_第2页
软件设计报告拼图游戏_第3页
软件设计报告拼图游戏_第4页
软件设计报告拼图游戏_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

年4月19日软件设计报告拼图游戏文档仅供参考,不当之处,请联系改正。软件设计报告题目:拼图游戏专业数字媒体技术学生姓名班级学号日期5月评分细则评分项优秀良好中等及格不及格平时表现(10%)程序演示(30%)报告(60%)评分等级等级:教师签名:年5月备注评分等级有五种:优秀、良好、中等、及格、不及格目录一、序言 20300\h1二、项目开发计划书 20301\h12.1技术可行性 20302\h12.2人员可能性 20303\h12.3代码工作量 20305\h12.4开发环境 20307\h1三、项目分析 13.1设计目标 13.2程序功能需求概述 1四、软件测试报告 6五、不足分析 9六、小结 9附1:代码 10附2:附录 20343\h24一、序言鉴于拼图游戏是一款较为经典的游戏,我们组选取了拼图游戏,借助Java-Eclipse这样一个开发环境完成此次软件工程实验项目。二、项目开发计划书2.1技术可行性我们组成员系统的学习了软件工程和Java的相关知识,具备一定的系统分析与设计能力,熟悉Java的设计与操纵;早期的大部分工作已经完成,因此后面的工作相对轻松:指导老师林巧民老师多年从事软件工程和程序设计的教学与研究工作,因而该系统的实现在技术上是可行的。2.2人员可能性程序的设计、编写与调试由杜宗泽、沙杰。文档的编写与整理,后期测试由陈凯负责。2.3代码工作量预计需一个星期左右。2.4开发环境开发环境:Java-Eclipse项目分析3.1设计目标按照软件工程的规范,以Java-Eclipse为前端开发工具,设计并实现一个拼图游戏。3.2程序功能需求概述实现载入3幅图片;设置字体;初始化界面;添加鼠标监听事件;面板初始化;单击鼠标时产生的事件;鼠标进入某个区域时产生的事件;鼠标突出某个区域时产生的事件;移动鼠标时产生的事件;拖动鼠标时产生的事件;按下鼠标时产生的事件;放开鼠标时产生的事件;转换坐标;图片初始化;判断程序是否结束;游戏初始化。软件测试报告在Java-Eclipse环境中调试、运行程序点击运行后出现如下画面:单击选取美女头像,初始状态如下图:此时可根据需要单击左上角“小程序”菜单进行功能选择,如下图:五、不足分析(1)4x4拼图难度较大;(2)右下角会有一块空缺,鉴于能力有限,未能完善。六、小结经过两个星期的努力,我们小组比较圆满地完成了本次课程设计的题目——拼图游戏。本练习制作拼图游戏的实例,运用了Java2中的图形处理技术和消息响应技术。经过图形技术,实现图片的导入和分割。经过消息响应机制,使程序能够响应用户的鼠标操作,进行拼图游戏的操作。在为期一周的学习实践中,最大的收获是锻炼了自己的编程能力。熟悉了Java-Eclipse开发环境。程序的编写是最为艰辛的过程。首先,由于没有较为深入的学习Java高级语言,我们小组在开始程序编写工作之前,借阅了相关的书籍,初步学习了Java语言中的各项功能。在又了一定的知识积累后,我才着手开始项目程序的编写。程序编写的灵魂在于算法的设计,因此我们组在这部分花费的精力也最多。算法比较复杂。刚开始由于思考的不够全面,编写的程序虽能勉强完成大概的功能需求,但还是出现了很多bug。后来经过对算法的重新审视,以及查阅相关的书籍,不断的修改已有程序,终于基本消除了bug。在程序的编写过程中,还出现了一些小的问题,特别是一些语言书写的规则,细节功能的实现着实让我们组大费了一些周折。自学了有关软件工程的知识,并能够把自学导的内容加以实践与应用。由于我没有选修这门课程,因此造成在实践过程中还是遇到了一些问题,比如在软件开发的初级阶段,与小组成员讨论系统功能的结构化设置时,就不能全面有效的构思清楚。幸好另外一名同组成员较系统地学习了这门课程,经过讨论,最后设计出了现在的程序。经过这次课程设计,我拓宽了知识面,锻炼了能力,综合素质得到较大提高。安排课程设计的基本目的,在于理论与实际的结合,人与人之间的沟通,特别是观察、分析和解决问题的实际工作能力,作为整个学习体系的有机组成部分,课程设计虽然只安排了两周进行,但并不具有绝对独立的意义。这次课程设计,让我找出了自身状况与实际需要的差距,并在以后的学习期间及时补充相关知识,为求职与正式工作做好充分的知识、能力准备,让我受益匪浅。代码部分importjava.awt.*;importjava.applet.*;importjava.awt.event.*;publicclasspintuextendsApplet implementsMouseListener,MouseMotionListener{ privateImagepicture; privateGraphicsbuffer; privateImagepic[]; privateImageoff_pic[]; privateGraphicsoff_buf[]; privateImageoff_screen; privateGraphicsoff_buffer; privateImageoff_drag; privateGraphicsoff_drag_buf; privateintmap[][]; privateintran[]; privateintwidth=0; privateintheight=0; privateintlastx; privateintlasty; privateintlast_downx; privateintlast_downy; privateintstepx; privateintstepy; privatebooleanchoose; privatebooleanclick[][]; privatebooleanm_down; privatebooleanm_drag; privatebooleannot_redraw; privatebooleanable; Fontfont1,font2; //程序的初始化 publicvoidinit() { resize(640,480); pic=newImage[3]; off_pic=newImage[16]; off_buf=newGraphics[16]; map=newint[4][4]; ran=newint[15]; for(inta=0;a<16;a++) map[a/4][a%4]=a; for(inta=0;a<15;a++) ran[a]=a; click=newboolean[4][4]; MediaTrackertracker=newMediaTracker(this); //要载入的图片 pic[0]=getImage(getCodeBase(),"PICTURE0.JPG"); pic[1]=getImage(getCodeBase(),"PICTURE1.JPG"); pic[2]=getImage(getCodeBase(),"PICTURE2.GIF"); tracker.addImage(pic[0],0); tracker.addImage(pic[1],0); tracker.addImage(pic[2],0); try{ tracker.waitForID(0); }catch(InterruptedExceptione){} //设置字体 font1=newFont("TimesRoman",Font.BOLD,48); font2=newFont("TimesRoman",Font.BOLD,32); width=640; height=480; //初始化主界面 initForm(); //添加鼠标监听事件 addMouseListener(this); addMouseMotionListener(this); } //面板初始化 voidinitForm() { this.setBackground(Color.orange); if(off_drag==null){ off_drag=createImage(width/4,height/4); off_drag_buf=off_drag.getGraphics(); } } publicvoidpaint(Graphicsg){ if(off_screen==null) { off_screen=createImage(width,height); off_buffer=off_screen.getGraphics(); } if(able){ off_buffer.setColor(Color.black); for(inta=0;a<4;a++) for(intb=0;b<4;b++) { if(map[a][b]!=15) off_buffer.drawImage(off_pic[map[a][b]],b*width/4,a*height/4,this); if(map[a][b]==15) off_buffer.fillRect(b*width/4,a*height/4,width/4,height/4); for(intc=0;c<2;c++) off_buffer.drawRect(b*width/4+c,a*height/4+c,width/4-c,height/4-c); if(click[a][b]) { off_buffer.setColor(Color.red); for(intd=0;d<2;d++) off_buffer.drawOval(b*width/4-d,a*height/4-d,width/4+d,height/4+d); off_buffer.setColor(Color.black); } } } else{ off_buffer.setColor(Color.orange); off_buffer.fillRect(0,0,640,480); off_buffer.setFont(font1); off_buffer.setColor(Color.red); off_buffer.drawImage(pic[2],30,50,250,180,this); off_buffer.drawImage(pic[0],370,160,250,180,this); off_buffer.drawImage(pic[1],60,270,250,180,this); off_buffer.drawString("ChooseOne!",320,100); } g.drawImage(off_screen,0,0,this); } publicvoidrepaint(){ paint(this.getGraphics()); } //单击鼠标时产生的事件 publicvoidmouseClicked(MouseEventevt){} //鼠标进入某个区域时产生的事件 publicvoidmouseEntered(MouseEventevt){} //鼠标退出某个区域时产生的事件 publicvoidmouseExited(MouseEventevt){} //移动鼠标时产生的事件 publicvoidmouseMoved(MouseEventevt){ if(!able){ Pointpoint; point=evt.getPoint(); if(point.x>30&&point.x<280&&point.y>50&&point.y<230) { off_buffer.setColor(Color.orange); off_buffer.fillRect(0,0,640,480); off_buffer.setFont(font1); off_buffer.drawImage(pic[2],25,45,250,180,this); off_buffer.drawImage(pic[0],370,160,250,180,this); off_buffer.drawImage(pic[1],60,270,250,180,this); off_buffer.setColor(Color.black); off_buffer.fillRect(30,225,250,5); off_buffer.fillRect(275,50,5,176); off_buffer.setColor(Color.red); off_buffer.drawString("picture2!",320,100); this.getGraphics().drawImage(off_screen,0,0,this); } elseif(point.x>370&&point.x<620&&point.y>160&&point.y<340) { off_buffer.setColor(Color.orange); off_buffer.fillRect(0,0,640,480); off_buffer.setFont(font1); off_buffer.drawImage(pic[2],30,50,250,180,this); off_buffer.drawImage(pic[0],365,155,250,180,this); off_buffer.drawImage(pic[1],60,270,250,180,this); off_buffer.setColor(Color.black); off_buffer.fillRect(370,335,250,5); off_buffer.fillRect(615,160,5,175); off_buffer.setColor(Color.red); off_buffer.drawString("picture0!",320,100); this.getGraphics().drawImage(off_screen,0,0,this); } elseif(point.x>60&&point.x<310&&point.y>270&&point.y<450) { off_buffer.setColor(Color.orange); off_buffer.fillRect(0,0,640,480); off_buffer.setFont(font1); off_buffer.drawImage(pic[2],30,50,250,180,this); off_buffer.drawImage(pic[0],370,160,250,180,this); off_buffer.drawImage(pic[1],55,265,250,180,this); off_buffer.setColor(Color.black); off_buffer.fillRect(60,445,250,5); off_buffer.fillRect(305,270,5,175); off_buffer.setColor(Color.red); off_buffer.drawString("picture1!",320,100); this.getGraphics().drawImage(off_screen,0,0,this); } else{ repaint(); } } } //拖动鼠标时产生的事件 publicvoidmouseDragged(MouseEventevt){ if(!able) return; if(m_down){ Pointpoint; Pointtemp; point=evt.getPoint(); m_drag=true; repaint(); Graphicsdavid=this.getGraphics(); if(!not_redraw) off_drag_buf.drawImage(off_pic[map[last_downy][last_downx]],0,0,this); david.drawImage(off_drag,point.x+stepx,point.y+stepy,this); not_redraw=true; } } //按下鼠标时产生的事件 publicvoidmousePressed(MouseEventevt){ if(!able) return; Pointpoint; Pointtemp; point=evt.getPoint(); if(getarea(point)==point) return; else{ temp=getarea(point); if(!m_down){ if(map[temp.y][temp.x]==15) return; else{ m_down=true; last_downx=temp.x; last_downy=temp.y; stepx=temp.x*160-point.x; stepy=temp.y*120-point.y; } } elseif(m_down){ m_down=false; } } } //放开鼠标时产生的事件 publicvoidmouseReleased(MouseEventevt){ if(able){ if(m_drag){ m_down=false;m_drag=false;not_redraw=false; Pointpoint; Pointtemp; point=evt.getPoint(); if(getarea(point)==point) { repaint(); return;} else{ temp=getarea(point); if(map[temp.y][temp.x]!=15){ repaint();return;} else{ if(Math.abs(last_downx-temp.x)==1&&last_downy-temp.y==0) { intdavid; david=map[last_downy][last_downx]; map[last_downy][last_downx]=15; map[temp.y][temp.x]=david; if(wingame()) able=false; repaint(); return; } elseif(last_downx-temp.x==0&&Math.abs(last_downy-temp.y)==1) { intdavid; david=map[last_downy][last_downx]; map[last_downy][last_downx]=15; map[temp.y][temp.x]=david; if(wingame()) able=false; repaint(); return; } else{repaint();return;} } } } } else{ Pointpoint; point=evt.getPoint(); if(point.x>30&&point.x<280&&point.y>50&&point.y<230) {able=true; initmap(2);} if(point.x>370&&point.x<620&&point.y>160&&point.y<340) {able=true;initmap(0);} if(point.x>60&&point.x<310&&point.y>270&&point.y<450) {able=true;initmap(1);} elsereturn; } } //转换坐标 publicPointgetarea(Pointpoint){ if(point.x>640||point.y>480) returnpoint; elsereturnpoint=ne

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论