俄罗斯方块代码Word文件下载.docx

上传人:b****5 文档编号:21340700 上传时间:2023-01-29 格式:DOCX 页数:40 大小:27.08KB
下载 相关 举报
俄罗斯方块代码Word文件下载.docx_第1页
第1页 / 共40页
俄罗斯方块代码Word文件下载.docx_第2页
第2页 / 共40页
俄罗斯方块代码Word文件下载.docx_第3页
第3页 / 共40页
俄罗斯方块代码Word文件下载.docx_第4页
第4页 / 共40页
俄罗斯方块代码Word文件下载.docx_第5页
第5页 / 共40页
点击查看更多>>
下载资源
资源描述

俄罗斯方块代码Word文件下载.docx

《俄罗斯方块代码Word文件下载.docx》由会员分享,可在线阅读,更多相关《俄罗斯方块代码Word文件下载.docx(40页珍藏版)》请在冰豆网上搜索。

俄罗斯方块代码Word文件下载.docx

Form

privateGamePalettem_GamePalette;

public策略()

InitializeComponent();

//显示的属性pbmainpalettepbnextpaletteformmain的属性

}//Application.Run(newFormMain());

FormMain_ShownpbNextPalette_PaintpbMainPalette_Paint

privatevoidpbMainPalette_Paint(objectsender,PaintEventArgse)

if(m_GamePalette!

=null)

m_GamePalette.PaintPalette(e.Graphics);

//背景设定为灰色

}

privatevoidpbNextPalette_Paint(objectsender,PaintEventArgse)

if(m_GamePalette!

=null)

m_GamePalette.PaintNext(e.Graphics);

//一开始就有一些图像信息如背景位图

privatevoid策略_KeyDown(objectsender,KeyEventArgse)

if(e.KeyCode==Keys.F2)

m_GamePalette.m_Score=0;

m_GamePalette.Close();

m_GamePalette=null;

TemplateArrayarray=newTemplateArray();

//privateArrayListm_List=newArrayList();

//m_List为一个动态数组

array.Add("

0000001000011100000000000"

Color.FromArgb(-128));

//get{returnm_List.Count;

0000000000111100000000000"

Color.FromArgb(-65536));

//m_List.Add(newBrickTemplate(code,color))

0000000110011000000000000"

Color.FromArgb(-16711936));

//array含有m_list与Count信息地址(public)

0000000100011100000000000"

Color.FromArgb(-4144960));

0000000100011000100000000"

Color.FromArgb(-16776961));

0000000000011100100000000"

Color.FromArgb(-65281));

0000001000011000110000000"

Color.FromArgb(-8323073));

m_GamePalette=newGamePalette(//publicGamePalette()

15,

25,

array,

20,

Color.Black,

pbMainPalette.CreateGraphics(),

pbNextPalette.CreateGraphics(),

pictureBox1.CreateGraphics(),

0,

Color.White,

false);

m_GamePalette.PaintScore();

m_GamePalette.InitRandomBrick();

m_GamePalette.Start();

else

if(m_GamePalette==null||m_GamePalette.IsGameover)

return;

if(e.KeyCode==Keys.F3)

if(m_GamePalette.IsRunning)m_GamePalette.Pause();

m_GamePalette.Resume();

elseif(e.KeyCode==Keys.Left)

m_GamePalette.MoveLeft();

elseif(e.KeyCode==Keys.Right)

m_GamePalette.MoveRight();

elseif(e.KeyCode==Keys.Down)

m_GamePalette.DropDown();

elseif(e.KeyCode==Keys.Up)

m_GamePalette.ContraRotate();

elseif(e.KeyCode==Keys.Space)

 

privatevoidbutton1_Click(objectsender,EventArgse)

privatevoidbutton2_Click(objectsender,EventArgse)

privatevoidbutton3_Click(objectsender,EventArgse)

privatevoidbutton4_Click(objectsender,EventArgse)

m_GamePalette.MoveDown();

privatevoidbutton5_Click(objectsender,EventArgse)

privatevoid策略_Shown(objectsender,EventArgse)

privatevoidpictureBox1_Paint(objectsender,PaintEventArgse)

partialclass策略

///必需的设计器变量。

privateSystem.ComponentModel.IContainercomponents=null;

///清理所有正在使用的资源。

paramname="

disposing"

>

如果应释放托管资源,为true;

否则为false。

<

/param>

protectedoverridevoidDispose(booldisposing)

if(disposing&

&

(components!

=null))

components.Dispose();

base.Dispose(disposing);

#regionWindows窗体设计器生成的代码

///设计器支持所需的方法-不要

///使用代码编辑器修改此方法的内容。

privatevoidInitializeComponent()

System.ComponentModel.ComponentResourceManagerresources=newSystem.ComponentModel.ComponentResourceManager(typeof(策略));

this.pbMainPalette=newSystem.Windows.Forms.PictureBox();

this.pbNextPalette=newSystem.Windows.Forms.PictureBox();

this.pictureBox1=newSystem.Windows.Forms.PictureBox();

((System.ComponentModel.ISupportInitialize)(this.pbMainPalette)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.pbNextPalette)).BeginInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();

this.SuspendLayout();

//

//pbMainPalette

this.pbMainPalette.Image=((System.Drawing.Image)(resources.GetObject("

pbMainPalette.Image"

)));

this.pbMainPalette.Location=newSystem.Drawing.Point(0,0);

this.pbMainPalette.Name="

pbMainPalette"

;

this.pbMainPalette.Size=newSystem.Drawing.Size(300,500);

this.pbMainPalette.TabIndex=0;

this.pbMainPalette.TabStop=false;

this.pbMainPalette.Paint+=newSystem.Windows.Forms.PaintEventHandler(this.pbMainPalette_Paint);

//pbNextPalette

this.pbNextPalette.Image=((System.Drawing.Image)(resources.GetObject("

pbNextPalette.Image"

this.pbNextPalette.Location=newSystem.Drawing.Point(306,12);

this.pbNextPalette.Name="

pbNextPalette"

this.pbNextPalette.Size=newSystem.Drawing.Size(100,100);

this.pbNextPalette.TabIndex=1;

this.pbNextPalette.TabStop=false;

this.pbNextPalette.Paint+=newSystem.Windows.Forms.PaintEventHandler(this.pbNextPalette_Paint);

//pictureBox1

this.pictureBox1.Image=((System.Drawing.Image)(resources.GetObject("

pictureBox1.Image"

this.pictureBox1.Location=newSystem.Drawing.Point(306,133);

this.pictureBox1.Name="

pictureBox1"

this.pictureBox1.Size=newSystem.Drawing.Size(100,150);

this.pictureBox1.TabIndex=2;

this.pictureBox1.TabStop=false;

this.pictureBox1.Paint+=newSystem.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

//策略

this.AutoScaleDimensions=newSystem.Drawing.SizeF(6F,12F);

this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize=newSystem.Drawing.Size(410,507);

this.Controls.Add(this.pictureBox1);

this.Controls.Add(this.pbNextPalette);

this.Controls.Add(this.pbMainPalette);

this.KeyPreview=true;

this.Name="

策略"

this.Text="

this.Shown+=newSystem.EventHandler(this.策略_Shown);

this.KeyDown+=newSystem.Windows.Forms.KeyEventHandler(this.策略_KeyDown);

((System.ComponentModel.ISupportInitialize)(this.pbMainPalette)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.pbNextPalette)).EndInit();

((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();

this.ResumeLayout(false);

#endregion

privateSystem.Windows.Forms.PictureBoxpbMainPalette;

privateSystem.Windows.Forms.PictureBoxpbNextPalette;

privateSystem.Windows.Forms.PictureBoxpictureBox1;

usingSystem.Collections;

//砖块列表信息类d

namespaceTetris.logic

classTemplateArray//定义了Add函数与Clear函数管理木块增减

privateArrayListm_List=newArrayList();

//创建m_List为一个动态数组

//获取砖块末班数

publicintCount

get{returnm_List.Count;

//获取砖块模板index下标return砖块模具

publicBrickTemplatethis[intindex]//BrickTemplate//砖块样色信息模板类(砖块样式编码,样色)BrickTemplate为格式

get{return(BrickTemplate)m_List[index];

}//返回m_List[index]下的(砖块样式编码,样色)m-list的元素下都有m-codem-color

//添加新砖块模板砖块样式编码颜色

publicvoidAdd(stringcode,Colorcolor)

m_List.Add(newBrickTemplate(code,color));

//接着执行BrickTemplate执行m_Code=code;

m_Color=color;

返回form1把m-Codem-Color的地址送给m-list

}//完毕后Code=m_CodeCode可改m-Code不能改

//清空砖块模板

publicvoidClear()

m_List.Clear();

{

classBrickTemplate//砖块样色信息模板类(砖块样式编码,样色)

privatestringm_Code;

privateColorm_Color;

//构造砖块信息code砖块编码字符串color砖块

publicBrickTemplate(stringcode,Colorcolor)

if(code==null||code.Length!

=25||color==Color.Empty)

{thrownewFormatException("

zhuankuaiyangshixinxicuowu!

"

);

m_Code=code;

}//返回后清空

//获取砖块样式编码

publicstringCode//使得外部变量Code与私有变量m_Code相等

get{returnm_Code;

}//使用BrickTemplate函数是已经赋值了的m_Code(=code);

//获取砖块颜色

publicColorColor////使得外部变量Color与m_Color私有变量相等

get{returnm_Color;

}

classBrick//构造砖块

privatePoint[]m_Points;

//zuobiaoprivate组织防止其它调用

privateintm_X;

//zhongdianzuobiao

privateintm_Y;

publicColorm_Color;

//zhuankuaiyanse

privateColorm_BgColor;

//beijingyanse

privateintm_BlockSize;

//danyuangexiangse

privateSolidBrushm_Brush;

//单色画笔,用来填充

//

//单点放大成矩形

privateRectanglePointToRect(Pointp)//由坐标返回:

坐标,宽长四要素

Rectangler=newRectangle((X+m_X+p.X)*m_BlockSize+1,//xRectangle贮存(坐标x,坐标y,宽,高)

(Y+m_Y+p.Y)*m_BlockSize+1,//ym_XY使Y从变化到heigh-2最后一行矮一点?

不Y在m_Runbrick=-y时已经被改变

m_BlockSize-2,//width因为单位格稍小

m_BlockSize-2);

//height

returnr;

//中点在(x+m_x,y+m_y)

//构造砖块:

sa砖块样式color砖块颜色bgcolor砖块背景颜色size砖块单位大小

publicBrick(Point[]sa,Colorcolor,ColorbgColor,intsize)//Brick(样式,砖颜色,背景颜色,大小)

m_Color=color;

m_BgColor=bgColor;

//赋值给privateRectanglePointToRect(Pointp)在显示时使用(返回r值时使用)

m_Bloc

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 工作计划

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

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