ImageVerifierCode 换一换
格式:DOCX , 页数:37 ,大小:293.72KB ,
资源ID:3457325      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3457325.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C#俄罗斯方块课设报告.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C#俄罗斯方块课设报告.docx

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

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

3、也一致,包括块的旋转,加速下降,平移,满行消去,到顶游戏结束功能;(2)能够自定义游戏中功能键的具体按键,设置游戏的级别,即方块下降的速等,并在设置后立即生效,在游戏中立刻体现,在下次程序运行时读取上次设置的游戏环境;(3)显示下一方块提示信息,以及游戏数据的统计,如速度,按键速度,分数行者等等;(4) 游戏有级别设置,级别越高,方块下降的速度越快,当到达一定分数后进入下一级别;二、制作过程2.1 新建C# 2010 项目打开 Visual C#.NET 2005,从主菜单中选择“文件”/ “新建”/ “项目”,在弹出的“新建项目”对话框中,在左侧“已安装的模板”中选择 Visaul C#/W

4、indows,在中间位置选择“windows 应用程序”,在“名称”中输入项目名称“RussiaBlock”,最后按确定按钮,建立新项目。如图 1 所示。图1.建立新项目“RussiaBlock”在编辑器右侧文件树上,鼠标右键单击Form1.cs,选择“重命名(M)”,修改名称为:MainForm.cs2.2在MainForm设计窗体中添加控件,构造界面2.3单击Mainform窗体空白处,在右下角属性表格中,找到KeyPreview属性,将值设置为true2.4为工程添加新类,名称:Block.cs双击新类Block.cs,进入编辑代码,添加引用using System.Drawing;us

5、ing System.Windows.Forms;2.5编辑类SnakeNode中代码,如下内容:namespace RussiaBlockpublic class Blockpublic Block(Control con, int leftBorder, int bottomBorder, int unitPix, int shapeNO, Point firstPos, Color color)this.con = con;this.leftBorder = leftBorder;this.bottomBorder = bottomBorder;this.unitPix = unitPi

6、x;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;/形状号private Control con;/绘图控件private Point pos;/当前位置private Point lastPos;/上一次位置private int lef

7、tBorder;/左边界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()foreach (Point p in this.lastPos)this.con.Invalidate(new Rectangle(p.X * unitPix, p.Y * unitPi

8、x, 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;pos0 = firstPos;switch (shapeNO)case 1:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2

9、= 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(firstPos.X + 3, firstPos.Y);break;case 3:pos1 = new Point(firstPos.X + 1, firstPos.Y);pos2

10、= 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 Point(firstPos.X + 2, firstPos.Y + 1);break;case 5:pos1 = new Point(firstPos.X + 1, firstPos.

11、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 = new Point(firstPos.X + 2, firstPos.Y);break;default:pos1 = new Point(firstPos.X + 1, firs

12、tPos.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)if (p.X - 1 this.leftBorder | this.hujip.X + 1, p.Y)canMove = false;break;elseforeach (Poi

13、nt 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 | p.Y this.bottomBorder | this.hujip.X, p.Y)canRotate = false;break;if (canRotate = true)

14、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;for (i = 0; i this.huji.GetLength(0); i+)if (hujii, p.Y = false)break;if (i = this.huji.Ge

15、tLength(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.unitPix, p.Y * unitPix, 25, 25);foreach (Point p in this.pos)this.DrawOne(p.X, p.Y, this.color

16、, 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 & row != lowRow)midRow = row;break;for (int j = 0; j = count; i-)for (int j = 0; j = coun

17、t; 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, i = false;con.Invalidate(new Rectangle(0, 0, con.Width, (lowRow + 1) * this.unitPix);thi

18、s.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, Color color)this.SetLastPos();this.EraseLast();this.SetPos(shapeNO, firstPos);if (!this.Can

19、Rotate(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;case 2:temp0.Offset(2, 2);temp1.Offset(1, 1);temp3.Offset(-1, -1);if (this.CanRotate(temp)thi

20、s.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;elserotated = false;break;case 4:temp0.Offset(2, 0);temp1.Offset(0, 2);if (this.CanRotate(temp)th

21、is.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);temp

22、3.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;break;case 7:temp0.Offset(1, 1);temp2.Offset(-1, -1);temp3.Offset(0, -2);if (this.CanRotate(temp)this.pos0.Offset(1, 1);this.pos2.Offset(-1, -1);this.

23、pos3.Offset(0, -2);this.shapeNO = 17;elserotated = false;break;case 8: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 = 2;elserotated = false;break;case 9:temp2.Offset(-1, -1);i

24、f (this.CanRotate(temp)this.pos2.Offset(-1, -1);this.shapeNO = 10;elserotated = false;break;case 10:temp3.Offset(-1, 1);if (this.CanRotate(temp)this.pos3.Offset(-1, 1);this.shapeNO = 11;elserotated = false;break;case 11:temp0.Offset(-1, 1);temp2.Offset(1, 1);temp3.Offset(1, -1);if (this.CanRotate(temp)this.pos0.Offset(-1, 1);this.pos2.Offset(1, 1);this.pos3.Offset(1, -1);this.shapeNO = 3;elserotated = false;break;case 12:temp0.Offset(-2, 0);temp0.Offset(0, -2);if (this.CanRotate(temp)this.pos0.Offset(-2, 0);this.pos1.Offset(0, -2);this.shapeNO = 4;elserotated = false;break;case 1

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1