| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 601 人关注过本帖
标题:谁可以说说俄罗斯方块源码的意思!
只看楼主 加入收藏
复仇军KK
Rank: 1
等 级:新手上路
帖 子:192
专家分:0
注 册:2006-1-3
收藏
 问题点数:0 回复次数:2 
谁可以说说俄罗斯方块源码的意思!

Public Cube(6, 4) As String '定义方块形状
Public intCube(4, 4) As Integer '用4x4的数组纪录当前方块形状
Public intTryCube(4, 4) As Integer '下个位置试图出现的方块形状
Public intnextCube(4, 4) As Integer '下一个方块的形状
Public intONcube(4, 4) As Integer '“下一个”提示框中的上一个方块形状
Public intNowcube As Integer '当前的方框种类
Public intNcube As Integer '下一个方框种类
Public intNowform As Integer '当前方框的形式
Public intNform As Integer '下一个方框的形式
Public intNowX As Integer '当前方框的显示位置横坐标
Public intNowY As Integer '..................纵....
Public intWidth As Integer '游戏区宽度,既一排可显示的方框数
Public intHeight As Integer '......高........列..............
Public intNew As Integer '是否为新下落的方块,用以决定是否擦除上一个方块
Sub defineCube() '方块形状
Cube(0, 1) = "11121314"
Cube(0, 2) = "12223242"
Cube(0, 3) = "11121314"
Cube(0, 4) = "12223242"
Cube(1, 1) = "12212223"
Cube(1, 2) = "12222332"
Cube(1, 3) = "11121322"
Cube(1, 4) = "12212232"
Cube(2, 1) = "11212223"
Cube(2, 2) = "12132232"
Cube(2, 3) = "11121323"
Cube(2, 4) = "13233233"
Cube(3, 1) = "13212223"
Cube(3, 2) = "12223233"
Cube(3, 3) = "11121321"
Cube(3, 4) = "12132333"
Cube(4, 1) = "11122223"
Cube(4, 2) = "13222332"
Cube(4, 3) = "11122223"
Cube(4, 4) = "13222332"
Cube(5, 1) = "12132122"
Cube(5, 2) = "12222333"
Cube(5, 3) = "12132122"
Cube(5, 4) = "12222333"
End Sub
Sub StoI(strS As String, Mode As Integer)
Dim i, j As Integer
If Mode = 0 Then
For i = 1 To 4
For j = 1 To 4
intCube(i, j) = 0
Next j
Next i
For i = 1 To 7 Step 2
intCube(Int(Mid(strS, i, 1)), Int(Mid(strS, i + 1, 1))) = 1
Next i
Else
If Mode = 2 Then
For i = 1 To 4
For j = 1 To 4
intTryCube(i, j) = 0
Next j
Next i
For i = 1 To 7 Step 2
intTryCube(Int(Mid(strS, i, 1)), Int(Mid(strS, i + 1, 1))) = 1
Next i
Else
For i = 1 To 4
For j = 1 To 4
intnextCube(i, j) = 0
Next j
Next i
For i = 1 To 7 Step 2
intnextCube(Int(Mid(strS, i, 1)), Int(Mid(strS, i + 1, 1))) = 1
Next i
End If
End If
End Sub
Sub gameInit()
Dim i As Integer
For i = 0 To frmMain.shpCube.ubound
frmMain.shpCube(i).Visible = False
Next i
Randomize
intNowX = 3
intNowY = 0
intNowcube = Int(Rnd * 6)
intNowform = Int(Rnd * 4) + 1
Call StoI(Cube(intNowcube, intNowform), 0)
Randomize
intNcube = Int(Rnd * 6)
intNform = Int(Rnd * 4) + 1
Call nextDisplay(intNcube, intNform)
frmMain.KeyPreview = True
frmMain.Label2.Visible = False
End Sub

Function cubeDisplay(X As Integer, Y As Integer, shape As Integer, cubeForm As Integer, Mode As Integer) As Integer
Dim i, j, n As Integer
Dim a As Integer 'mode=1:change mode=0:down
a = 1
StoI Cube(intNowcube, intNowform), 0
If intNew <> 1 Then
For i = 1 To 4
For j = 1 To 4
If intCube(i, j) = 1 Then
n = (intNowY + i - 1) * intWidth + intNowX + j - 1
frmMain.shpCube(n).Visible = False
End If
Next j
Next i
End If
StoI Cube(shape, cubeForm), 2
For i = 1 To 4
For j = 1 To 4
If intTryCube(i, j) = 1 Then
If i + Y > intHeight Then
a = -1
GoTo out
End If
If Mode = 1 Then
If j + X > intWidth Then
a = 0
GoTo out
End If
If j + X < 1 Then
a = 0
GoTo out
End If
n = (Y + i - 1) * intWidth + X + j - 1
If frmMain.shpCube(n).Visible = True Then
a = 0
GoTo out
End If
Else
n = (Y + i - 1) * intWidth + X + j - 1
If frmMain.shpCube(n).Visible = True Then
a = -1
GoTo out
End If
End If
End If
Next j
Next i
out:
If a = 1 Then
StoI Cube(shape, cubeForm), 0
For i = 1 To 4
For j = 1 To 4
If intCube(i, j) = 1 Then
n = (Y + i - 1) * intWidth + X + j - 1
frmMain.shpCube(n).Visible = True
End If
Next j
Next i
intNowX = X
intNowY = Y
intNowform = cubeForm
Else
For i = 1 To 4
For j = 1 To 4
If intCube(i, j) = 1 Then
n = (intNowY + i - 1) * intWidth + intNowX + j - 1
frmMain.shpCube(n).Visible = True
End If
Next j
Next i
End If
cubeDisplay = a
End Function

Sub nextDisplay(shape As Integer, cubeForm As Integer)
Dim i, j, n As Integer
StoI Cube(shape, cubeForm), 1
For i = 1 To 4
For j = 1 To 4
If intONcube(i, j) = 1 Then
n = (i - 1) * 4 + j - 1
frmMain.Shape1(n).Visible = False
End If
Next j
Next i
For i = 1 To 4
For j = 1 To 4
If intnextCube(i, j) = 1 Then
n = (i - 1) * 4 + j - 1
frmMain.Shape1(n).Visible = True
End If
Next j
Next i
For i = 1 To 4
For j = 1 To 4
intONcube(i, j) = intnextCube(i, j)
Next j
Next i
End Sub
Sub clearRow()
Dim i, j, n, k, m As Integer
Dim ok As Integer
For i = 0 To intHeight - 1
ok = 1
For j = 0 To intWidth - 1
n = i * intWidth + j
If frmMain.shpCube(n).Visible = False Then
ok = 0
Exit For
End If
Next j
If ok = 1 Then

For k = i To 1 Step -1
For m = 0 To intWidth - 1
n = k * intWidth + m
frmMain.shpCube(n).Visible = frmMain.shpCube(n - 10).Visible
Next m
Next k
End If
Next i
End Sub

版主能帮我解说一下这些语句的意思吗?我是新学的.!!麻烦一下了.!~~

Private Sub Form_Load()
Dim i, intH, intW As Integer
For i = 0 To 199
If i > 0 Then Load shpCube(i)
intWidth = 10
intHeight = 20

[此贴子已经被作者于2006-1-3 16:09:48编辑过]

搜索更多相关主题的帖子: 俄罗斯方块 源码 
2006-01-03 16:09
lineageII
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-12-22
收藏
得分:0 

你把全部工程发上来吧

2006-01-03 17:46
Linyj
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2005-10-13
收藏
得分:0 
呵呵,那么多啊!

世间上最珍贵的永恒的幸福:就是平凡; 人生中最长久的拥有:就是珍惜。
2006-01-03 23:43
快速回复:谁可以说说俄罗斯方块源码的意思!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022123 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved