資源簡介
C#俄羅斯方塊完整源碼+注釋,用VS2010可以順利編譯,編譯生成后可運行游戲,界面沒有過多美化,看上去似乎挺簡單的那種。代碼注釋豐富:
public Point firstPoi = new Point(140, 20);//定義方塊的起始位置
public static Color[,] PlaceColor;//記錄方塊的位置
public static bool[,] Place;//記錄方塊的位置
public static int conWidth = 0;//記錄列數
public static int conHeight = 0;//記錄行數
public static int maxY = 0;//方塊在行中的最小高度
public static int conMax = 0;//方塊落下后的最大位置
public static int conMin = 0;//方塊落下后的最小位置
bool[] tem_Array = { false, false, false, false };//記錄方塊組中那一塊所在行中已滿
Color ConColor = Color.Coral;
Point[] ArryPoi = new Point[4];//方塊的數組
Point[] Arryfront = new Point[4];//前一個方塊的數組
int Cake = 20;//定義方塊的大小
int Convertor = 0;//變換器
Control Mycontrol = new Control();//實例化Control
public Label Label_Linage = new Label();//實例化Label,用于顯示去除的行數
public Label Label_Fraction = new Label();//實例化Label,用于顯示分數
public static int[] ArrayCent = new int[] { 2, 5, 9, 15 };//記錄加分情況

代碼片段和文件信息
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;
//Download?by?http://www.codefans.net
namespace?俄羅斯方塊
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????Russia?MyRussia?=?new?Russia();//實例化Russia類,用于操作游戲
????????Russia?TemRussia?=?new?Russia();//實例化Russia類,用于生成下一個方塊樣式
????????public?static?int?CakeNO?=?0;//記錄下一個方塊樣式的標識
????????public?static?bool?become?=?false;//判斷是否生成下一個方塊的樣式
????????public?static?bool?isbegin?=?false;//判斷當前游戲是否開始
????????public?bool?ispause?=?true;//判斷是否暫停游戲
????????public?Timer?timer?=?new?Timer();
?
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{
????????????MyRussia.ConvertorClear();//清空整個控件
????????????MyRussia.firstPoi?=?new?Point(140?20);//設置方塊的起始位置
????????????label3.Text?=?“0“;//顯示去除的行數
????????????label4.Text?=?“0“;//顯示分數
????????????MyRussia.Label_Linage?=?label3;//將label3控件加載到Russia類中
????????????MyRussia.Label_Fraction?=?label4;//將label4控件加載到Russia類中
????????????timer1.Interval?=?500;//下移的速度
????????????timer1.Enabled?=?false;//停止計時
????????????timer1.Enabled?=?true;//開始計時
????????????Random?rand?=?new?Random();//實例化Random
????????????CakeNO?=?rand.Next(1?8);//獲取隨機數
????????????MyRussia.CakeMode(CakeNO);//設置方塊的樣式
????????????MyRussia.Protract(panel1);//繪制組合方塊
????????????beforehand();//生成下一個方塊的樣式
????????????MyRussia.PlaceInitialization();//初始化Random類中的信息
????????????isbegin?=?true;//判斷是否開始
????????????ispause?=?true;
????????????MyRussia.timer?=?timer1;
????????????button2.Text?=?“暫?!?
????????????ispause?=?true;
????????????textBox1.Focus();//獲取焦點
????????}
????????///?
????????///?生成下一個方塊的樣式
????????///?
????????public?void?beforehand()
????????{
????????????Graphics?P3?=?panel3.CreateGraphics();
????????????P3.FillRectangle(new?SolidBrush(Color.Black)?0?0?panel3.Width?panel3.Height);
????????????Random?rand?=?new?Random();//實例化Random
????????????CakeNO?=?rand.Next(1?8);//獲取隨機數
????????????TemRussia.firstPoi?=?new?Point(50?30);//設置方塊的起始位置
????????????TemRussia.CakeMode(CakeNO);//設置方塊的樣式
????????????TemRussia.Protract(panel3);//繪制組合方塊
????????}
????????private?void?Form1_KeyDown(object?sender?KeyEventArgs?e)
????????{
????????????if?(!isbegin)//如果沒有開始游戲
????????????????return;
????????????if?(!ispause)//如果游戲暫停
????????????????return;
????????????if?(e.KeyCode?==?Keys.Up)//如果當前按下的是↑鍵
????????????????MyRussia.MyConvertorMode();//變換當前方塊的樣式
????????????if?(e.KeyCode?==?Keys.Down)//如果當前按下的是↓鍵
????????????{
????????????????timer1.Interval?=?300;//增加下移的速度
????????????????MyRussia.ConvertorMove(0);//方塊下移
????????????}
????????????if?(e.KeyCode?==?Keys.Left)//如果當前按下的是←鍵
????????????????MyRussia.ConvertorMove(1);//方塊左移
????????????if?(e.KeyCode?==?Keys.Right)//如果當前按下的是→鍵
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6076??2013-06-07?14:14??okba
?????文件???????8679??2013-06-07?14:14??okba
?????文件???????6008??2013-06-07?14:14??okba
?????文件????????496??2013-06-07?14:14??okba
?????文件???????1362??2013-06-07?14:14??okba
?????文件???????2880??2013-06-07?14:14??okba
?????文件???????5612??2013-06-07?14:14??okba
?????文件???????1100??2013-06-07?14:14??okba
?????文件????????249??2013-06-07?14:14??okba
?????文件??????28122??2013-06-07?14:14??okba
?????文件???????3813??2013-06-07?14:14??okba
?????文件????????935??2013-06-07?14:14??okba
?????文件??????16384??2013-06-07?14:14??okba
?????目錄??????????0??2013-06-07?14:14??okba
?????目錄??????????0??2013-06-07?14:14??okba
?????目錄??????????0??2013-06-07?14:14??okba
?????目錄??????????0??2013-06-07?14:14??okba
-----------?---------??----------?-----??----
????????????????81716????????????????????17
- 上一篇:用ASP.NET實現簡單的辦公用品管理系統
- 下一篇:python 天氣CSV文件
評論
共有 條評論