Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
'these are for sound
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10
Public Type Player
X As Integer
Y As Integer
Dire As Byte
End Type
Public Type Goal
X As Integer
Y As Integer
Tag As Byte
End Type
Public P1 As Player '<-- The player
Public G1 As Goal '<-- The Goal
Public Board() As Boolean
Public Width As Integer
Public Height As Integer
Public FlagDead As Boolean
Public Const Size As Byte = 30
Public Sub LoadMap()
Main.picMap.AutoSize = False
Main.picMap.Picture = LoadPicture(App.Path & "\map.bmp") 'load the board form file
Main.picMap.AutoSize = True
Width = Main.picMap.ScaleWidth 'get the height and width of the board
Height = Main.picMap.ScaleHeight
ReDim Board(1 To Width, 1 To Height)
For Y = 1 To Height
For X = 1 To Width
a = Main.picMap.Point(X - 1, Y - 1) 'Get the color of this pixel
Select Case a
Case 0 'if it's black, do nothing
Case vbBlue 'If it's blue...
P1.X = X '... Set player startpoint to here...
P1.Y = Y
Board(X, Y) = True '... and mark it as walkable
Case vbRed 'if it's Red...
G1.X = X '... move the goal to here...
G1.Y = Y
Board(X, Y) = True '... and mark it as walkable
Case Else
Board(X, Y) = True 'if it's any other color, mark it as walkable