資源簡介
疊方塊游戲源碼
源碼描述:
界面出現(xiàn)后,點(diǎn)擊開始按鈕開始游戲,把鼠標(biāo)移動到游戲區(qū)域,鼠標(biāo)變?yōu)槭郑?這時候單擊左鍵,方塊停止移動,如果方塊停止時,它和它所在行的下面所有行都能被一條直線串起來,
那么繼續(xù)游戲,同時方塊所在行的上一行出現(xiàn)新的方塊移動,否則游戲結(jié)束
方塊分布為4443332211(注:第一層4個,第十層1個)
越往上移動速度越快,方塊越少,難度會越來越大
歡迎感興趣的用戶下載學(xué)習(xí)

代碼片段和文件信息
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;//網(wǎng)格的寬高
????????int?mGridWidth?=?27;
????????bool[]?isFill;????//記錄每個格子是否被填充
????????bool?IsLeft?=?false;????//方塊是否往左運(yùn)動
????????int?clickNum;?//點(diǎn)擊次數(shù)?增加難度用
?????????????
????????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();
????????}
????????//繪制網(wǎng)格
????????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);//繪制網(wǎng)格
????????}
????????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個文件信息
評論
共有 條評論