C#俄罗斯方块

考虑三个主要事件来实现游戏开发中描述的行为:
(1) 窗体加载时候,创建第一个方块
(2) 窗体的KeyPress事件可以处理来自用户的输入
(3) 定时器控件实现“每个时钟设置点调用Down方法”产生预想的下落效果

伪码如下所示

Form_Load
Creates an object (named currentBlock) of block class

Form_KeyPress
If left Arrow was pressed , call left method of currentBlock
If right Arrow was pressed , call right method of currentBlock
If up Arrow was pressed , call rotate method of currentBlock
If down Arrow was pressed , call down method of currentBlock


TimerTick
If there is no block below currentBlock ,
and the currentBlock didn't reach the bottom of the screen then
Call the down method of currentBlock
Else
Stop the block
If it's at the top of the screen then
The Game is over
If we filled any horizontal lines then
Increase the Game Score
Erase the line
Create a new block at the top of the screen

编码阶段
概略设计 : 编写 square 类
第二阶段设计 : 编写block类
最终设计 : 编写GameField和游戏引擎
C#做的俄罗斯方块游戏using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Xml; using System.IO; using System.Security.Cryptography; using System.Text; using System.Runtime.Serialization.Formatters.Binary; namespace RussiaBlock { public class MainForm : System.Windows.Forms.Form { #region 变量 private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Timer timer1; private Block block; private Block nextBlock; private int nextShapeNO; private bool paused; private DateTime atStart; private DateTime atPause; private TimeSpan pauseTime; private System.Windows.Forms.Panel panel3; private System.Windows.Forms.TextBox textBox1; private ControlForm sform; private Keys[] keys; private System.Windows.Forms.Label label4; private int level; private int startLevel; private bool trans; private int rowDelNum; private bool failed; private System.Windows.Forms.Label label5; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.MenuItem menuItem6; private AxWMPLib.AxWindowsMediaPlayer axMediaPlayer1; private System.Windows.Forms.MenuItem menuItem7; private System.ComponentModel.IContainer components; #endregion public MainForm() { InitializeComponent(); } protected override void Dispose( bool disposing ) { if( disposing ) { if(component
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值