没有合适的资源?快使用搜索试试~ 我知道了~
基于C#俄罗斯方块设计.doc
1 下载量 114 浏览量
2022-11-13
10:20:47
上传
评论
收藏 744KB DOC 举报
温馨提示
试读
19页
基于C#俄罗斯方块设计.doc
资源推荐
资源详情
资源评论
.
精选 word,可编辑!
此程序主要三个小结讲解:
1、 设计方块类(block.cs)
2、 设计游戏类(game.cs)
3、 设计窗体类(form1.cs)
通俗易懂,希望对广大的学生们都有帮助
欢迎下载
技术 qq 1278263100
游戏所需图片:
游戏运行图:
.
精选 word,可编辑!
话不多说:
设计方块类(block.cs)
程序都有注释,通俗易懂
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;//add
namespace 俄罗斯方块
{
public class Block
{
private short width;
private short height;
private short top;
private short left;
private int ID; //方块部件的 ID
public int[,] shape; //存储方块部件的形状,0为空白,1为有砖块
public Block()//构造函数
{
Random randomGenerator = new Random();
int randomBlock = randomGenerator.Next(1, 5);//产生 1—4 的数
this.ID = randomBlock;
switch (this.ID)
{
case 1: //横条形
this.Width = 4;
this.Height = 1;
this.Top = 0;
this.Left = 3;
shape = new int[this.Width, this.Height];
shape[0, 0] = 1; shape[1, 0] = 1;
shape[2, 0] = 1; shape[3, 0] = 1;
break;
case 2: //正方形
this.Width = 2;
this.Height = 2;
this.Top = 0;
this.Left = 4;
// Creates the new shape for this block.
shape = new int[this.Width, this.Height];
shape[0, 0] = 1; shape[0, 1] = 1;
.
精选 word,可编辑!
shape[1, 0] = 1;shape[1, 1] = 1;
break;
case 3: //T形
this.Width = 3;
this.Height = 3;
this.Top = 0;
this.Left = 4;
// Creates the new shape for this block.
shape = new int[this.Width, this.Height];
shape[0, 0] = 1; shape[1, 0] = 1;
shape[2, 0] = 1; shape[1, 1] = 1;
shape[1, 2] = 1;
break;
case 4: //L 形
this.Width = 2;
this.Height = 3;
this.Top = 0;
this.Left = 4;
// Creates the new shape for this block.
shape = new int[this.Width, this.Height];
shape[0, 0] = 1; shape[0, 1] = 1;
shape[0, 2] = 1; shape[1, 2] = 1;
break;
}
}
public short Width//Width 属性
{
get
{
return width;
}
set
{
width = value;
}
}
public short Height//Height 属性
{
get
{
return height;
}
set
{
剩余18页未读,继续阅读
资源评论
matlab大师
- 粉丝: 2434
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功