📄 w_main.srw
字号:
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type mdi_1 from mdiclient within w_main
end type
type st_14 from statictext within w_main
end type
type st_13 from statictext within w_main
end type
type st_12 from statictext within w_main
end type
type st_8 from statictext within w_main
end type
type dw_fklx from datawindow within w_main
end type
type st_zfs from statictext within w_main
end type
type st_10 from statictext within w_main
end type
type st_9 from statictext within w_main
end type
type st_zhs from statictext within w_main
end type
type st_7 from statictext within w_main
end type
type st_6 from statictext within w_main
end type
type st_5 from statictext within w_main
end type
type st_4 from statictext within w_main
end type
type st_2 from statictext within w_main
end type
type st_1 from statictext within w_main
end type
type pb_start from picturebutton within w_main
end type
type pb_stop from picturebutton within w_main
end type
type pb_5 from picturebutton within w_main
end type
type pb_4 from picturebutton within w_main
end type
type pb_3 from picturebutton within w_main
end type
type pb_2 from picturebutton within w_main
end type
type pb_1 from picturebutton within w_main
end type
type st_over from statictext within w_main
end type
type dw_2 from datawindow within w_main
end type
type dw_1 from datawindow within w_main
end type
type st_3 from statictext within w_main
end type
type timing_2 from timing within w_main
end type
type timing_1 from timing within w_main
end type
end forward
shared variables
decimal{18} isi_cont = 0
end variables
global type w_main from window
integer width = 1330
integer height = 1888
boolean titlebar = true
string title = "俄罗斯方块"
string menuname = "m_main"
boolean controlmenu = true
boolean minbox = true
windowtype windowtype = mdihelp!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
mdi_1 mdi_1
st_14 st_14
st_13 st_13
st_12 st_12
st_8 st_8
dw_fklx dw_fklx
st_zfs st_zfs
st_10 st_10
st_9 st_9
st_zhs st_zhs
st_7 st_7
st_6 st_6
st_5 st_5
st_4 st_4
st_2 st_2
st_1 st_1
pb_start pb_start
pb_stop pb_stop
pb_5 pb_5
pb_4 pb_4
pb_3 pb_3
pb_2 pb_2
pb_1 pb_1
st_over st_over
dw_2 dw_2
dw_1 dw_1
st_3 st_3
timing_2 timing_2
timing_1 timing_1
end type
global w_main w_main
type variables
str_fk istr_fk_Current[4] // 当前正在使用的方块阵列
str_fk istr_fk_last[4] // 即将使用的方块阵列
str_fk istr_fk_null[4] // 空方块
Integer ii_CurrentX,ii_CurrentY // 当前方块所在的行及列
Decimal idec_Timer = 0.25 // 定时器速度
Boolean ib_IsBegin = False,ib_IsStop = False
Long il_fkid,il_fkh // 当前方块编号,方块号
Long il_Lastfkid,il_lastfkh // 下次 方块编号,方块号
Long il_dj,il_line // 等级,底行数
Long il_zhs,il_zfs // 总行数,总分数
boolean ib_keydown = false
end variables
forward prototypes
public subroutine wf_writefk (datawindow adw_dw, str_fk astr_fk[], integer ai_row, integer ai_col, boolean ab_isdel)
public function boolean wf_candown (str_fk astr_fk[], integer ai_row, integer ai_col)
public function boolean wf_canleft (str_fk astr_fk[], integer ai_row, integer ai_col)
public function boolean wf_canright (str_fk astr_fk[], integer ai_row, integer ai_col)
public function boolean wf_is_over ()
public function boolean wf_getfk (long al_fkid, long al_fkh)
public subroutine wf_xz ()
public subroutine wf_init_line (integer al_line)
public subroutine wf_new_fk ()
public function integer wf_del_line ()
public subroutine wf_keydown (keycode key)
public subroutine wf_new ()
public subroutine wf_edit ()
end prototypes
public subroutine wf_writefk (datawindow adw_dw, str_fk astr_fk[], integer ai_row, integer ai_col, boolean ab_isdel);// 将所给的方块阵列画入所给的数据窗口指定行中
// 注意:考虑到可能同时进行其它写操作,这个函数并不设置所给数据窗口的SetRedraw属性,
// 为了避免闪烁,在调用前及后应该进行处理
// 参数:datawindow adw_dw 写在哪个数据窗口中
// str_fk astr_fk 将要写的方块阵列(固定为四行)
// integer ai_row 开始行
// integer ai_col 开始列
// Boolean ab_IsDel 是否擦除
Integer li_r,li_c,li_x = 0,li_y = 0
Long ll_fk
For li_r = ai_Row To ai_Row + 3
li_y ++
If li_r > 0 And li_r < 22 Then // 行的范围是 1 到 21
li_x = 0
For li_c = ai_col To ai_col + 3
li_x ++
If li_c > 0 And li_c < 11 Then // 列的范围是 1 到 10
Choose Case li_x
Case 1
ll_fk = astr_fk[li_y].long1
Case 2
ll_fk = astr_fk[li_y].long2
Case 3
ll_fk = astr_fk[li_y].long3
Case 4
ll_fk = astr_fk[li_y].long4
End Choose
If ll_fk > 0 Then // 有需要画的方块点
If ab_IsDel Then // 擦除
adw_dw.object.data[li_r,li_c] = 0
Else // 画方块点
adw_dw.object.data[li_r,li_c] = ll_fk
End If
End If
End If
End For
End If
End For
Return
end subroutine
public function boolean wf_candown (str_fk astr_fk[], integer ai_row, integer ai_col);// 判断所给的方块是否可以下落
// 参数:str_fk astr_fk 将要写的方块阵列(固定为四行)
// integer ai_row 方块阵列当前所在行
// integer ai_col 方块阵列当前所在列
// 返回:Boolean
Boolean lb_Result = False
Integer li_row,li_col,li_y,li_x
Boolean lb_IsHave = False
li_x = 0
For li_Col = ai_col To ai_col + 3
li_x ++
If li_col > 0 And li_col < 11 Then // 下降不判断左右超界的点
li_y = 5
For li_row = ai_Row + 4 To ai_Row + 1 Step -1
li_y --
// 当前方块阵列所在点有方块才需要判断
lb_IsHave = False
Choose Case li_x
Case 1
If astr_fk[li_y].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不须判断,继续上一行
Continue
End If
If li_Row > 21 Then // 因为是下落,不判断是否行小于1的问题
// 超出行范围,不能下落了
Goto ExitFunction
ElseIf li_Row > 0 Then
// 在可显示行范围内,则判断将下落的点上是否已经有方块了
If dw_1.Object.data[li_row,li_col] > 0 Then
// 如果有,则判断是否是本身的
If li_y + 1 > 4 Then
Goto ExitFunction
Else
lb_IsHave = False
Choose Case li_x
Case 1
If astr_fk[li_y + 1].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y + 1].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y + 1].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y + 1].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不是自已的方块
Goto ExitFunction
End If
End If
Else
Continue
End If
End If
End For
End If
End For
lb_Result = True
ExitFunction:
return lb_Result
end function
public function boolean wf_canleft (str_fk astr_fk[], integer ai_row, integer ai_col);// 判断所给的方块是否可以左移
// 参数:str_fk astr_fk 将要写的方块阵列(固定为四行)
// integer ai_row 方块阵列当前所在行
// integer ai_col 方块阵列当前所在列
// 返回:Boolean
Boolean lb_Result = False
Integer li_row,li_col,li_y,li_x
Boolean lb_IsHave = False
li_y = 0
For li_row = ai_Row To ai_Row + 3
li_y ++
li_x = 0
For li_col = ai_col - 1 To ai_Col + 2
li_x ++
// 当前方块阵列所在点有方块才需要判断
lb_IsHave = False
Choose Case li_x
Case 1
If astr_fk[li_y].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不须判断,继续下一列
Continue
End If
If li_Col < 1 Then
Goto ExitFunction
ElseIf li_col < 11 Then
If li_Row > 0 And li_row < 22 Then // 左移不管超界的行
If dw_1.Object.data[li_row,li_col] > 0 Then
// 如果有,则判断是否是本身的
If li_x - 1 < 1 Then
Goto ExitFunction
Else
lb_IsHave = False
Choose Case li_x - 1
Case 1
If astr_fk[li_y].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不是自已的方块
Goto ExitFunction
End If
End If
End If
Else
Continue
End If
End If
End For
End For
lb_Result = True
ExitFunction:
return lb_Result
end function
public function boolean wf_canright (str_fk astr_fk[], integer ai_row, integer ai_col);// 判断所给的方块是否可以右移
// 参数:str_fk astr_fk 将要写的方块阵列(固定为四行)
// integer ai_row 方块阵列当前所在行
// integer ai_col 方块阵列当前所在列
// 返回:Boolean
Boolean lb_Result = False
Integer li_row,li_col,li_y,li_x
Boolean lb_IsHave = False
li_y = 0
For li_row = ai_Row To ai_Row + 3
li_y ++
li_x = 0
For li_col = ai_col + 1 To ai_Col + 4
li_x ++
// 当前方块阵列所在点有方块才需要判断
lb_IsHave = False
Choose Case li_x
Case 1
If astr_fk[li_y].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不须判断,继续下一列
Continue
End If
If li_Col > 10 Then
Goto ExitFunction
ElseIf li_col > 0 Then
If li_Row > 0 And li_row < 22 Then // 右移不管超界的行
If dw_1.Object.data[li_row,li_col] > 0 Then
// 如果有,则判断是否是本身的
If li_x + 1 > 4 Then
Goto ExitFunction
Else
lb_IsHave = False
Choose Case li_x + 1
Case 1
If astr_fk[li_y].long1 > 0 Then
lb_IsHave = True
End If
Case 2
If astr_fk[li_y].long2 > 0 Then
lb_IsHave = True
End If
Case 3
If astr_fk[li_y].long3 > 0 Then
lb_IsHave = True
End If
Case 4
If astr_fk[li_y].long4 > 0 Then
lb_IsHave = True
End If
End Choose
If lb_ishave = False Then // 没点,不是自已的方块
Goto ExitFunction
End If
End If
End If
Else
Continue
End If
End If
End For
End For
lb_Result = True
ExitFunction:
return lb_Result
end function
public function boolean wf_is_over ();// 判断游戏是否结束
Integer li_r,li_c,li_x,li_y,li_step
Boolean lb_IsOver = False
li_y = 0
For li_r = ii_CurrentY To ii_CurrentY + 3
li_y ++
If li_r < 1 Then
li_x = 0
For li_c = ii_CurrentX To ii_CurrentX + 3
li_x ++
Choose Case li_x
Case 1
lb_IsOver = (istr_fk_current[li_y].long1 > 0)
Case 2
lb_IsOver = (istr_fk_current[li_y].long2 > 0)
Case 3
lb_IsOver = (istr_fk_current[li_y].long3 > 0)
Case 4
lb_IsOver = (istr_fk_current[li_y].long4 > 0)
End Choose
If lb_Isover Then
Goto Over
End If
End For
Else
Exit
End If
End For
Over:
If lb_IsOver Then // 游戏结束
st_Over.Visible = True
ib_IsBegin = False
ib_IsStop = False
End If
Return lb_IsOver
end function
public function boolean wf_getfk (long al_fkid, long al_fkh);// 取方块到结构中
boolean lb_result = false
Long ll_find
ll_find = dw_fklx.find('id = ' + string(al_fkid),1,dw_fklx.RowCount())
If ll_find <= 0 Then
Return false
End If
string ls_fk
Long ll_color
ll_color = dw_fklx.object.fkcolor[ll_find]
Choose case al_fkh
Case 1
ls_fk = dw_fklx.object.fk1[ll_find]
case 2
ls_fk = dw_fklx.object.fk2[ll_find]
Case 3
ls_fk = dw_fklx.object.fk3[ll_find]
Case 4
ls_fk = dw_fklx.object.fk4[ll_find]
End choose
integer li_r,li_c
long ll_l
For li_r = 1 to 4
For li_c = 1 to 4
If left(ls_fk,1) = '0' Then
ll_l = rgb(0,0,0)
Else
ll_l = ll_color
End If
Choose case li_c
Case 1
istr_fk_last[li_r].long1 = ll_l
Case 2
istr_fk_last[li_r].long2 = ll_l
Case 3
istr_fk_last[li_r].long3 = ll_l
Case 4
istr_fk_last[li_r].long4 = ll_l
End Choose
ls_fk = mid(ls_fk,2)
End For
ls_fk = mid(ls_fk,2)
End for
lb_result = true
Return lb_Result
end function
public subroutine wf_xz ();// 旋转方块
boolean lb_result = false
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -