资源简介
叠方块游戏源码
源码描述:
界面出现后,点击开始按钮开始游戏,把鼠标移动到游戏区域,鼠标变为十字,
这时候单击左键,方块停止移动,如果方块停止时,它和它所在行的下面所有行都能被一条直线串起来,
那么继续游戏,同时方块所在行的上一行出现新的方块移动,否则游戏结束
方块分布为4443332211(注:第一层4个,第十层1个)
越往上移动速度越快,方块越少,难度会越来越大
欢迎感兴趣的用户下载学习
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//下载于51aspx.com
namespace RectGame
{
public partial class MainForm : Form
{
// int mTimeInterval = 0;//时间间隔
int mPBWidth = 0; //绘图控件的宽
int mPBHeight = 0; //绘图控件的高
int mGridHeight = 27;//网格的宽高
int mGridWidth = 27;
bool[] isFill; //记录每个格子是否被填充
bool IsLeft = false; //方块是否往左运动
int clickNum; //点击次数 增加难度用
int tempX;
int tempY;
int tempLenNum; //方块占几个格子
Graphics mGraphics;
public MainForm()
{
InitializeComponent();
clickNum = 0;
isFill = new bool[10 10];
tempX = 0;
tempY = mGridHeight * 9;
tempLenNum = 4; //初始化方块的长度
timer1.Interval =85;
mPBWidth = pictureBox1.Width;//获取图像控件的高和宽
mPBHeight = pictureBox1.Height;
mGraphics = pictureBox1.CreateGraphics();
}
//绘制网格
private void DrawGrid(int mPBWidth int mPBHeight Graphics g int mGridHeight int mGridWidth)
{
SolidBrush pBrush = new SolidBrush(Color.Green);
Pen p = new Pen(pBrush);
for (int i = 0; i <= mPBWidth / mGridWidth; i++)
{
g.DrawLine(p i * mGridHeight 0 i * mGridHeight mPBHeight);
}
for (int j = 0; j <= mPBHeight / mGridHeight; j++)
{
g.DrawLine(p 0 j * mGridWidth mPBWidth j * mGridWidth);
}
}
private void pictureBox1_Paint(object sender PaintEventArgs e)
{
DrawRect(tempX tempY tempLenNum e.Graphics);
DrawFilledRect(isFill e.Graphics);
DrawGrid(mPBWidth mPBHeighte.Graphics 27 27);//绘制网格
}
private void btnStart_Click(object sender EventArgs e)
{
clickNum = 0;
isFill = new bool[10 10];
tempX = 0;
tempY = mGridHeight * 9;
tempLenNum = 4; //初始化方块的长度
timer1.Interval = 85;
pictureBox1.CreateGraphics().Clear(pictureBox1.BackColor);
tempX = 0;
tempY = mGridHeight * 9;
timer1.Enabled = true;
timer1.Start();
//绘制最下面一行的方块 从左往右移动 长度=4
// DrawMoveRect(10 4 mGraphics);
}
///
/// 填充第row行 长度为p的长方形
///
///
///
private void DrawRect(int tempXint tempYint pGraphics pGraphics)
{
SolidBrush mBrush=new SolidBrush(Color.Red);
pGraphics.FillRectangle(mBrushtempX tempY mGrid
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 30720 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Debug\RectGame.exe
....... 26112 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Debug\RectGame.pdb
....... 14328 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Debug\RectGame.vshost.exe
....... 490 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Debug\RectGame.vshost.exe.manifest
....... 30720 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Release\RectGame.exe
....... 28160 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Release\RectGame.pdb
....... 14328 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Release\RectGame.vshost.exe
....... 490 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\bin\Release\RectGame.vshost.exe.manifest
....... 6896 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Form1.cs
....... 3732 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Form1.Designer.cs
....... 6008 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Form1.resx
....... 1890 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.csproj.FileListAbsolute.txt
....... 890 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.csproj.GenerateResource.Cache
....... 30720 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.exe
....... 180 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.MainForm.resources
....... 26112 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.pdb
....... 19472 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\RectGame.Properties.Resources.resources
....... 4608 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
....... 638 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.csproj.FileListAbsolute.txt
....... 890 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.csproj.GenerateResource.Cache
....... 30720 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.exe
....... 180 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.MainForm.resources
....... 28160 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.pdb
....... 19472 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\RectGame.Properties.Resources.resources
....... 4608 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\obj\Release\TempPE\Properties.Resources.Designer.cs.dll
....... 492 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Program.cs
....... 1369 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Properties\AssemblyInfo.cs
....... 3097 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Properties\Resources.Designer.cs
....... 6205 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Properties\Resources.resx
....... 1093 2012-09-26 10:56 51aspx_RangeBlockGamec8f7f815-7484-4469-bf0b-a2b92472da5a\Properties\Settings.Designer.cs
............此处省略19个文件信息
相关资源
- 汽车票订票系统源码20110803
- 博客BLOG
- qq邮箱源码
- 百度贴吧爱丽丝源码
- 微票-微信小程序源码
- 算术表达式求值源码+实验报告
- 狼人杀小程序
- 学习cocos2d-x 3.0自己写的游戏2048
- 用zlib库在内存中解压或压缩http会话中
- 兵河五四v0.6源码
- leveldb源码
- wifidog官方源码
- 小清新网站模板源码
- 连连看 程序框架代码C 语言版
- 微信公众号生成推广二维码源码
- 骷髅头硬盘锁源码
- 《DirectX 11游戏编程入门》中文版+英文
- unity项目源码 仿dnf demo
- 由unity3d开发的《最后一战》手游全套
- OA办公自动化项目源码及视频讲解教程
- OpenGL编程指南(第八版)中文高清晰
- unity3D5.x 游戏开发技术详解与典型案例
- osg视频教程
- 三种方法实现图像的分割含程序源码
- 汇编语言写的时钟小程序
- 数字魔板游戏源代码
- 小程序源码 仿百度小说
- vc播放avi的源程序
- Saliency Detection with Multi-Scale Superpixel
- Saliency Detection via Absorbing Markov Chain 中
评论
共有 条评论