欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    俄罗斯方块游戏课设报告.docx

    • 资源ID:13379716       资源大小:456KB        全文页数:48页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    俄罗斯方块游戏课设报告.docx

    1、俄罗斯方块游戏课设报告j 成 绩 评 定 表学生姓名班级学号专 业计算机科学与技术课程设计题目俄罗斯方块游戏评语组长签字: 成绩日期 2014年 1 月14 日课程设计任务书学 院信息科学与工程学院专 业计算机科学与技术学生姓名班级学号课程设计题目俄罗斯方块游戏实践教学要求与任务:本系统为一个用C#实现的为我们所熟悉的简单的俄罗斯方块游戏,该系统的具体功能如下:(1)能简便的开始游戏,游戏中的方块的功能与日常我们所熟悉的游戏的功能 一致,各种块的设置也一致,包括块的旋转,加速下降,平移,满行消去,到顶游戏结束功能;(2)能够自定义游戏中功能键的具体按键,设置游戏的级别,即方块下降的速等,并在设

    2、置后立即生效,在游戏中立刻体现,在下次程序运行时读取上次设置的游戏环境;(3)显示下一方块提示信息,以及游戏数据的统计,如速度,按键速度,分数行者等等;(4) 游戏有级别设置,级别越高,方块下降的速度越快,当到达一定分数后进入下一级别; 工作计划与进度安排:第19周: 软件设计,编码调试,书写课设报告,答辩。指导教师: 2013年12月26日专业负责人:2013年12 月27日学院教学副院长:2013年12月28日一、 要求和规范1、需求分析 本系统为一个用C#实现的为我们所熟悉的简单的俄罗斯方块游戏,该系统的具体功能如下: 【1】 能简便的开始游戏,游戏中的方块的功能与日常我们所熟悉的游戏的

    3、功能一致,各种块的设置也一致,包括块的旋转,加速下降,平移,满行消去,到顶游戏结束功能; 【2】 能够自定义游戏中功能键的具体按键,设置游戏的级别,即方块下降的速度等,并在设置后立即生效,在游戏中立刻体现,在下次程序运行时读取上次设置的游戏环境; 【3】显示下一方块提示信息,以及游戏数据的统计,如速度,按键速度,分数行者等等; 【4】游戏有级别设置,级别越高,方块下降的速度越快,当到达一定分数后进入下一级别;2、界面要求要求界面简洁美观,简单易用。3.设计环境本程序选择Visual Studio 2010作为实验环境。二、设计思路1、用面向对象的方法分析系统对于俄罗斯方块来说,我们可以定义一个

    4、类,专门来描述俄罗斯方块,在这个类中,包含与之相关的方法、属性和字段,通过封装,实现其业务逻辑。其中,每一个俄罗斯方块都有相同的特征,由4个小正方形构成,有旋转,移动,下落的动作,行被填满除去构成行的小正方体块。基中块的形状类型有7种:田、一、L、倒L、Z、倒Z、上。在主窗口中,通过调用俄罗斯方块类来实现程序的表示层,在该窗口中通过两个Panel控件来实现方块叠放窗口和下一方块信息窗口;调用设置窗口,保存设计窗口类传回的信息,并设置到游戏中去,保存在配置文件中;2、概要设计根据设计思路,可以为系统设计三个类,实现俄罗斯方块其本块的类RussiaBlock继承Object类,主窗体类MainFo

    5、rm类。3、流程图 4、软件开发过程1、新项目的建立 打开 Visual C#.NET 2005,从主菜单中选择“文件”/ “新建”/ “项目”,在弹出的“新建 项目”对话框中,在左侧“已安装的模板”中选择 Visaul C#/Windows,在中间位置选择 “windows 应用程序”,在“名称”中输入项目名称“RussiaBlock”,最后按确定按钮, 建立新项目。如图 1 所示图1.建立新项目“RussiaBlock” 在编辑器右侧文件树上,鼠标右键单击Form1.cs,选择“重命名(M)”,修改名称为:MainForm.cs2、主界面的建立 从工具箱中选择合适的控件,加入窗体中。 例如

    6、:添加 Label 控件,修改右下侧属性列表中(Name)为 Label1,属性 Text 为手速:如图2所 其余控件按下表1所列添加。图2.Label 控件的添加序控件类型属性名称 属性值 1Label(name)Lable1Text手速: ForeColorRed 2Label(name)Lable2Text块数: ForeColorRed 3Label(name)Lable3 Text行数: ForeColorRed 4Label(name)Lable4 Text级别: ForeColorRed 5panel(name)panel1 size251,501 ForeColorBlack

    7、Location12,12 6panel(name)Panel2 size81,48 ForeColorBlack Location16,8 (放入 panel3 中) 7panel(name)Panel3 size112, 72 ForeColorBlack Location300,128button(name)button1Text开始9button(name)Button4 Text暂停 10timer (name)Timer1 Interval20011TextBox(name)TextBox1size1,21 Location388,338 表1.添加控件数据 主界面完成后效果如图3

    8、所示。图3. 主界面示意图3、程序的编写(1) 为工程添加新类,名称:Block.cs双击新类Block.cs,进入编辑代码,添加引用using System.Drawing;using System.Windows.Forms;(2)编辑类SnakeNode中代码,如下内容:namespace RussiaBlockpublic class Blockpublic Block(Control con, int leftBorder, int bottomBorder, int unitPix, int shapeNO, Point firstPos, Color color)this.con

    9、 = con;this.leftBorder = leftBorder;this.bottomBorder = bottomBorder;this.unitPix = unitPix;this.SetPos(shapeNO, firstPos);this.color = color;this.huji = new boolleftBorder + 1, bottomBorder + 1;this.iori = new ColorleftBorder + 1, bottomBorder + 1;this.lastPos = new Point4;private int shapeNO;/形状号p

    10、rivate Control con;/绘图控件private Point pos;/当前位置private Point lastPos;/上一次位置private int leftBorder;/左边界private int bottomBorder;/下边界private int unitPix;/每块象素数private int blockNum = 0;private int rowDelNum = 0;private bool, huji;private Color, iori;private Color color;/当前块颜色public void EraseLast()fore

    11、ach (Point p in this.lastPos)this.con.Invalidate(new Rectangle(p.X * unitPix, p.Y * unitPix, unitPix + 1, unitPix + 1);private void SetLastPos()for (int i = 0; i this.pos.Length; i+)this.lastPosi = this.posi;private void SetPos(int shapeNO, Point firstPos)this.shapeNO = shapeNO;this.pos = new Point4

    12、;pos0 = firstPos;switch (shapeNO)case 1:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X, firstPos.Y + 1);pos3 = new Point(firstPos.X + 1, firstPos.Y + 1);break;case 2:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X + 2, firstPos.Y);pos3 = new Point(f

    13、irstPos.X + 3, firstPos.Y);break;case 3:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X + 1, firstPos.Y + 1);pos3 = new Point(firstPos.X + 2, firstPos.Y);break;case 4:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X + 1, firstPos.Y + 1);pos3 = new Poi

    14、nt(firstPos.X + 2, firstPos.Y + 1);break;case 5:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X + 1, firstPos.Y - 1);pos3 = new Point(firstPos.X + 2, firstPos.Y - 1);break;case 6:pos1 = new Point(firstPos.X, firstPos.Y + 1);pos2 = new Point(firstPos.X + 1, firstPos.Y);pos3 =

    15、 new Point(firstPos.X + 2, firstPos.Y);break;default:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2 = new Point(firstPos.X + 2, firstPos.Y);pos3 = new Point(firstPos.X + 2, firstPos.Y + 1);break;private bool CanMove(int direction)bool canMove = true;if (direction = 0)foreach (Point p in this.pos)

    16、if (p.X - 1 this.leftBorder | this.hujip.X + 1, p.Y)canMove = false;break;elseforeach (Point p in this.pos)if (p.Y + 1 this.bottomBorder | this.hujip.X, p.Y + 1)canMove = false;break;return canMove;private bool CanRotate(Point pos)bool canRotate = true;foreach (Point p in pos)if (p.X this.leftBorder

    17、 | p.Y this.bottomBorder | this.hujip.X, p.Y)canRotate = false;break;if (canRotate = true)this.SetLastPos();return canRotate;private void DelRows()int count = 0;int highRow = 20;int lowRow = -1;int delRow = -1, -1, -1, -1 ;foreach (Point p in this.pos)if (p.Y = highRow | p.Y = lowRow)continue;int i;

    18、for (i = 0; i this.huji.GetLength(0); i+)if (hujii, p.Y = false)break;if (i = this.huji.GetLength(0)delRowcount = p.Y;if (p.Y lowRow)lowRow = p.Y;count+;if (count 0)/-Graphics gra = con.CreateGraphics();foreach (Point p in this.lastPos)gra.FillRectangle(new SolidBrush(con.BackColor), p.X * this.unit

    19、Pix, p.Y * unitPix, 25, 25);foreach (Point p in this.pos)this.DrawOne(p.X, p.Y, this.color, gra);foreach (int i in delRow)if (i 0)for (int j = 0; j 1)for (int i = lowRow; i highRow + 1; i-)for (int j = 0; j = count; i-)for (int j = 0; j 2)int midRow = -1;foreach (int row in delRow)if (row != highRow

    20、 & row != lowRow)midRow = row;break;for (int j = 0; j = count; i-)for (int j = 0; j = count; i-)for (int j = 0; j this.huji.GetLength(0); j+)this.hujij, i = this.hujij, i - count;this.iorij, i = this.iorij, i - count;for (int i = 0; i count; i+)for (int j = 0; j this.huji.GetLength(0); j+)this.hujij

    21、, i = false;con.Invalidate(new Rectangle(0, 0, con.Width, (lowRow + 1) * this.unitPix);this.rowDelNum += count;public void FixBlock()this.blockNum+;foreach (Point p in this.pos)this.hujip.X, p.Y = true;this.iorip.X, p.Y = this.color;this.DelRows();public bool GeneBlock(int shapeNO, Point firstPos, C

    22、olor color)this.SetLastPos();this.EraseLast();this.SetPos(shapeNO, firstPos);if (!this.CanRotate(this.pos)this.pos = null;return false;elsethis.color = color;return true;public bool Rotate()bool rotated = true;Point temp = pos0, pos1, pos2, pos3 ;switch (this.shapeNO)case 1:rotated = false;break;cas

    23、e 2:temp0.Offset(2, 2);temp1.Offset(1, 1);temp3.Offset(-1, -1);if (this.CanRotate(temp)this.pos0.Offset(2, 2);this.pos1.Offset(1, 1);this.pos3.Offset(-1, -1);this.shapeNO = 8;elserotated = false;break;case 3:temp0.Offset(1, -1);if (this.CanRotate(temp)this.pos0.Offset(1, -1);this.shapeNO = 9;elserot

    24、ated = false;break;case 4:temp0.Offset(2, 0);temp1.Offset(0, 2);if (this.CanRotate(temp)this.pos0.Offset(2, 0);this.pos1.Offset(0, 2);this.shapeNO = 12;elserotated = false;break;case 5:temp2.Offset(-1, 0);temp3.Offset(-1, 2);if (this.CanRotate(temp)this.pos2.Offset(-1, 0);this.pos3.Offset(-1, 2);this.shapeNO = 13;elserotated = false;break;case 6:temp0.Offset(1, 1);temp1.Offset(2, 0);temp3.Offset(-1, -1);if (this.CanRotate(temp)this.pos0.Offset(1, 1);this.pos1.Offset(2, 0);this.pos3.Offset(-1, -1);this.shapeNO = 14;elserotated = false;


    注意事项

    本文(俄罗斯方块游戏课设报告.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开