考虑三个主要事件来实现游戏开发中描述的行为:
(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和游戏引擎
(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和游戏引擎