pacfrm.frm
来自「吃豆子游戏的源代码。 嘿嘿」· FRM 代码 · 共 1,452 行 · 第 1/4 页
FRM
1,452 行
Top = 225
Width = 330
End
Begin VB.Image MetalFood
Height = 330
Left = 585
Top = 225
Width = 330
End
Begin VB.Image MetalBack
Height = 6270
Left = 405
Top = 180
Width = 6270
End
Begin VB.Image MetalWall
Height = 330
Index = 0
Left = 90
Top = 180
Width = 330
End
End
Begin VB.Image DeadImg
Height = 330
Left = 3645
Top = 4320
Visible = 0 'False
Width = 330
End
Begin VB.Label InfoLabel
AutoSize = -1 'True
BackColor = &H000000FF&
Caption = "DRUNK"
BeginProperty Font
Name = "Small Fonts"
Size = 5.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FFFF&
Height = 120
Left = 4365
TabIndex = 3
Top = 4995
Visible = 0 'False
Width = 465
End
Begin VB.Image Food
Height = 330
Index = 0
Left = 3780
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Wall
Height = 330
Index = 0
Left = 5670
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Berry
Height = 330
Index = 0
Left = 4095
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Protect
Height = 330
Index = 0
Left = 4725
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Life
Height = 330
Index = 0
Left = 5040
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Cherry
Height = 330
Index = 0
Left = 5355
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image Ghoul
Height = 375
Index = 0
Left = 3150
Top = 4320
Width = 510
End
Begin VB.Image PacMan
Height = 375
Left = 2565
Top = 5040
Width = 375
End
Begin VB.Image Beer
Height = 330
Index = 0
Left = 4410
Top = 5130
Visible = 0 'False
Width = 330
End
Begin VB.Image GhoulPic
Height = 330
Index = 3
Left = 4905
Top = 4320
Visible = 0 'False
Width = 330
End
Begin VB.Image GhoulPic
Height = 330
Index = 2
Left = 4590
Top = 4320
Visible = 0 'False
Width = 330
End
Begin VB.Image GhoulPic
Height = 330
Index = 1
Left = 4275
Top = 4320
Visible = 0 'False
Width = 330
End
Begin VB.Image GhoulPic
Height = 330
Index = 4
Left = 3960
Top = 4320
Visible = 0 'False
Width = 330
End
Begin VB.Image PacDown
Height = 330
Index = 1
Left = 3060
Top = 5715
Visible = 0 'False
Width = 330
End
Begin VB.Image PacDown
Height = 330
Index = 0
Left = 3060
Top = 5400
Visible = 0 'False
Width = 330
End
Begin VB.Image PacRight
Height = 330
Index = 1
Left = 2745
Top = 5715
Visible = 0 'False
Width = 330
End
Begin VB.Image PacLeft
Height = 330
Index = 1
Left = 2430
Top = 5715
Visible = 0 'False
Width = 330
End
Begin VB.Image PacUp
Height = 330
Index = 1
Left = 2115
Top = 5715
Visible = 0 'False
Width = 330
End
Begin VB.Image PacUp
Height = 330
Index = 0
Left = 2115
Top = 5400
Visible = 0 'False
Width = 330
End
Begin VB.Image PacRight
Height = 330
Index = 0
Left = 2745
Top = 5400
Visible = 0 'False
Width = 330
End
Begin VB.Image PacLeft
Height = 330
Index = 0
Left = 2430
Top = 5400
Visible = 0 'False
Width = 330
End
End
End
Attribute VB_Name = "MainFrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim LastDirection As Integer 'last dir of pacman
Dim MouthOpen As Integer 'is pacmans mouth open(1) or not(0)
Dim BeerCollected As Boolean 'is pacman drunk
Dim ProtectCollected As Boolean 'is pacman protected
Dim DrunkTime As Integer 'time he is drunk
Dim ProtectTime As Integer 'time he is protected
Public Sub LoadNextLevel() 'load the next level
If CurrLevel = 9 Then FinishGame Completed: Exit Sub 'see if all 9 levels have been finished
LevNum.Caption = Str(Int(CurrLevel + 1)) 'update the level caption on the loading screen
Loading.Visible = True 'show the loading screen
Loading.Refresh
Dim LevelNumber As String
Area.Enabled = False '\
GhoulTimer.Enabled = False ' |--disable the main parts of the game
EatTimer.Enabled = False '/
Call GameMod.UnloadArrays 'unload all objects on the cuurent level
EatenFood = 0 '\
WallCount = 0 ' |--reste values
FoodCount = 0 '/
CurrLevel = CurrLevel + 1 ' update the current level number
ThisDir "levels" 'goto the correct directory
LevelNumber = Trim(Str(CurrLevel)) 'convert the currlevel into a string
LoadMap "Level" & LevelNumber & ".PML" 'load the level file
SetSchWall 'set the wall pictures to the current schemes walls
GhoulTimer.Enabled = True '\
EatTimer.Enabled = True ' |-Enable main parts of the game
Area.Enabled = True '/
Loading.Visible = False 'loading is done
Info.Caption = "READY" 'show ready in corner
Info.Visible = True
Pause 1.5
Info.Caption = "GO!" 'show GO! in corner
Pause 0.7
Info.Caption = "Level " & CurrLevel 'show current level in corner
End Sub
'key has been pressed
Private Sub Area_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next 'Errors Only Happen If This Runs While Unloading
Dim Check As Integer ' check for an object
Dim Index As Integer ' current array index
If NowDead = True Then Exit Sub 'exit if pacman is dead
If BeerCollected = True Then 'reverse keys because pacman is drunk
Select Case KeyCode
Case vbKeyUp 'if up then down
KeyCode = vbKeyDown
Case vbKeyDown 'if down then up
KeyCode = vbKeyUp
Case vbKeyLeft 'if left then right
KeyCode = vbKeyRight
Case vbKeyRight 'if right then left
KeyCode = vbKeyLeft
End Select
End If
Select Case KeyCode 'select which key has been selected
Case vbKeyUp 'the up key has been pressed
LastDirection = dirUp
PacMan.Picture = PacUp(MouthOpen).Picture 'change pacmans mouth status
If PacMan.Top <= 330 Then GoTo NextStep: 'if pacman is on the top line and direction is up, exit this part of the sub
If CheckForAllFoodTypes(dirUp) = True Then GoTo MU: 'check for food, if there is, there is no need to check fo a wall
If IsWallThere(MainFrm.PacMan, 1) = False Then 'check for a wall
MU:
PacMan.Top = PacMan.Top - Grid 'there is no wall, move pacman up
End If
Case vbKeyDown
'--------------------------------------------'
' each case is set out the same as the first '
'--------------------------------------------'
LastDirection = dirDown
PacMan.Picture = PacDown(MouthOpen).Picture
If PacMan.Top >= Int((MapHeight * Grid) - (2 * Grid)) Then GoTo NextStep:
If CheckForAllFoodTypes(dirDown) = True Then GoTo MD:
If IsWallThere(MainFrm.PacMan, 2) = False Then
MD:
PacMan.Top = PacMan.Top + Grid
End If
Case vbKeyLeft
'--------------------------------------------'
' each case is set out the same as the first '
'--------------------------------------------'
LastDirection = dirLeft
PacMan.Picture = PacLeft(MouthOpen).Picture
If PacMan.Left <= Grid Then GoTo NextStep:
If CheckForAllFoodTypes(dirLeft) = True Then GoTo ML:
If IsWallThere(MainFrm.PacMan, 3) = False Then
ML:
PacMan.Left = PacMan.Left - Grid
End If
Case vbKeyRight
'--------------------------------------------'
' each case is set out the same as the first '
'--------------------------------------------'
PacMan.Picture = PacRight(MouthOpen).Picture
LastDirection = dirRight
If PacMan.Left >= Int((MapWidth * Grid) - (Grid * 2)) Then GoTo NextStep:
If CheckForAllFoodTypes(dirRight) = True Then GoTo MR:
If IsWallThere(MainFrm.PacMan, 4) = False Then
MR:
PacMan.Left = PacMan.Left + Grid
End If
End Select
NextStep:
If ProtectCollected = False Then 'if pacman is not protected then see if PM is dead
For Index = 2 To Ghoul.Count 'go through each ghoul
If NowDead = True Then Exit Sub 'if he's dead exit this sub
If Ghoul(Index).Top = PacMan.Top And Ghoul(Index).Left = PacMan.Left Then Reset_Level 'see if they are in the same place
Next Index
Else
If InBltLoop = False Then UpdateShieldPos 'update the shield bitblt
End If
If BeerCollected = True Then UpdateInfoLabelPos 'update the pos of the "drunck" label
If ProtectCollected = True Then 'update the shield bitblt
'blt the mask
Call BitBlt(Area.hDC, _
Int(PacMan.Left / Screen.TwipsPerPixelX), _
Int(PacMan.Top / Screen.TwipsPerPixelY), _
22, 22, ShieldPicMsk.hDC, 0, 0, SRCAND)
'blt the colour
Call BitBlt(Area.hDC, _
Int(PacMan.Left / Screen.TwipsPerPixelX), _
Int(PacMan.Top / Screen.TwipsPerPixelY), _
22, 22, ShieldPic.hDC, 0, 0, SRCPAINT)
End If
End Sub
Public Sub Reset_Level() 'pacman has died
Dim Index As Integer
NowDead = True
PacMan.ZOrder 0
PacMan.Picture = DeadImg.Picture
Area.Enabled = False '--disable main parts
GhoulTimer.Enabled = False '-^
EatTimer.Enabled = False '^
Pause 2
If Str(Val(Lives)) <= 0 Then FinishGame died 'has got game over
PacMan.Top = PacManPos.Y '\
PacMan.Left = PacManPos.X ' \
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?