home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD141801262001.psc / Mod.bas < prev   
Encoding:
BASIC Source File  |  2000-02-16  |  5.5 KB  |  165 lines

  1. Attribute VB_Name = "Module1"
  2. 'map numbers, each number in txt file = the const name
  3. Global screenw As Long
  4. Global screenh As Long
  5. Public Const Grass As Long = 1
  6. Public Const Tree As Long = 2
  7. Public Const Hole As Long = 3
  8. Public Const Front As Long = 4
  9. Public Const Back As Long = 5
  10. Public Const Leftt As Long = 6
  11. Public Const Rightt As Long = 7
  12. Public Const FrontD As Long = 8
  13. Public Const BackD As Long = 10
  14. Public Const LeftD As Long = 12
  15. Public Const RightD As Long = 14
  16. Public Const FrontU As Long = 9
  17. Public Const BackU As Long = 11
  18. Public Const LeftU As Long = 13
  19. Public Const RightU As Long = 15
  20. Public Const Mist As Long = 16
  21. Public Const Pistol As Long = 17
  22. Public Const Shotgun As Long = 18
  23. Public Const Mines As Long = 19
  24. Public Const LeftCorner As Long = 20
  25. Public Const Wall As Long = 21
  26. Public Const RightCorner As Long = 22
  27. Public Const LeftUpWall As Long = 23
  28. Public Const RightUpWall As Long = 24
  29. Public Const LeftBackCorner As Long = 25
  30. Public Const BackWall As Long = 26
  31. Public Const RightBackCorner As Long = 27
  32. 'for remebering what key was pressed
  33. Public Key As String
  34. Public Key2 As String
  35. 'for reading the map txt
  36. Public MapRead As String
  37. Public MapWriteR As Long
  38. Public MapWriteC As Long
  39. Dim MapLength As Long
  40. Dim Loopy As Long
  41. Dim Loopy2 As Long
  42. 'for storing the map
  43. Global data(400, 400) As String
  44. Global dRow As Integer
  45. Global dCol As Integer
  46. 'constants for controls
  47. Public Const DirUp As Integer = 1
  48. Public Const DirDown As Integer = 2
  49. Public Const DirLeft As Integer = 3
  50. Public Const DirRight As Integer = 4
  51. 'opponents position
  52. Global enemyX As Integer
  53. Global enemyY As Integer
  54. Global receiveMap As Boolean
  55. 'startpoints
  56. Global startscrX(10) As Integer
  57. Global startscrY(10) As Integer
  58. Global startpointX(10) As Integer
  59. Global startpointY(10) As Integer
  60. Global stp As Integer
  61.  
  62.  
  63. Sub LoadMap(FilePath As String)
  64. Open FilePath For Input As #1
  65. MapWriteR = 0
  66. MapWriteC = 0
  67. Do
  68.     On Error GoTo Done
  69.     Line Input #1, MapRead
  70.     MapLength = Len(MapRead)
  71.     For Loopy = 1 To MapLength
  72.         data(MapWriteR, MapWriteC) = Mid(MapRead, Loopy, 1)
  73.         If data(MapWriteR, MapWriteC) = "*" Then
  74.             startscrX(stp) = 1
  75.             MapWriteRB = MapWriteR
  76.             Do While MapWriteRB >= 10
  77.             MapWriteRB = MapWriteRB - 10
  78.             startscrX(stp) = startscrX(stp) + 1
  79.             Loop
  80.             
  81.             startpointX(stp) = MapWriteRB + 1
  82.             
  83.             startscrY(stp) = 1
  84.             MapWriteCB = MapWriteC
  85.             Do While MapWriteCB >= 13
  86.             MapWriteCB = MapWriteCB - 13
  87.             startscrY(stp) = startscrY(stp) + 1
  88.             Loop
  89.             
  90.             startpointY(stp) = MapWriteCB + 1
  91.             stp = stp + 1
  92.         End If
  93.         MapWriteC = MapWriteC + 1
  94.     Next
  95.     MapWriteC = 0
  96.     MapWriteR = MapWriteR + 1
  97. Loop
  98. Done:
  99. Close #1
  100. End Sub
  101.  
  102. Sub level1(XMap As Integer, YMap As Integer)
  103. For Loopy = 0 To 129
  104.     GameForm.sq(Loopy).Tag = ""
  105.     GameForm.sq(Loopy).Cls
  106. Next Loopy
  107. For Loopy = 0 To 9
  108.     For Loopy2 = 0 To 12
  109.         dRow = Loopy + ((XMap * 10) - 10)
  110.         dCol = Loopy2 + ((YMap * 13) - 13)
  111.         If data(dRow, dCol) = "" Or data(dRow, dCol) = " " Then
  112.             AddImage Loopy + 1, Loopy2 + 1, Mist, "solid"
  113.         ElseIf data(dRow, dCol) = "0" Then
  114.             AddImage Loopy + 1, Loopy2 + 1, Grass
  115.         ElseIf data(dRow, dCol) = "1" Then
  116.             AddImage Loopy + 1, Loopy2 + 1, Tree, "solid"
  117.         ElseIf data(dRow, dCol) = "2" Then
  118.             AddImage Loopy + 1, Loopy2 + 1, Hole
  119.         ElseIf data(dRow, dCol) = "3" Then
  120.             AddImage Loopy + 1, Loopy2 + 1, LeftCorner, "solid"
  121.         ElseIf data(dRow, dCol) = "4" Then
  122.             AddImage Loopy + 1, Loopy2 + 1, Wall, "solid"
  123.         ElseIf data(dRow, dCol) = "5" Then
  124.             AddImage Loopy + 1, Loopy2 + 1, RightCorner, "solid"
  125.         ElseIf data(dRow, dCol) = "6" Then
  126.             AddImage Loopy + 1, Loopy2 + 1, LeftUpWall, "solid"
  127.         ElseIf data(dRow, dCol) = "7" Then
  128.             AddImage Loopy + 1, Loopy2 + 1, RightUpWall, "solid"
  129.         ElseIf data(dRow, dCol) = "8" Then
  130.             AddImage Loopy + 1, Loopy2 + 1, LeftBackCorner, "solid"
  131.         ElseIf data(dRow, dCol) = "9" Then
  132.             AddImage Loopy + 1, Loopy2 + 1, BackWall, "solid"
  133.         ElseIf data(dRow, dCol) = "a" Then
  134.             AddImage Loopy + 1, Loopy2 + 1, RightBackCorner, "solid"
  135.         ElseIf data(dRow, dCol) = "b" Then
  136.             AddImage Loopy + 1, Loopy2 + 1, Pistol, "pistol"
  137.         ElseIf data(dRow, dCol) = "c" Then
  138.             AddImage Loopy + 1, Loopy2 + 1, Shotgun, "shotgun"
  139.         ElseIf data(dRow, dCol) = "d" Then
  140.             AddImage Loopy + 1, Loopy2 + 1, Mines, "mines"
  141.         ElseIf data(dRow, dCol) = "*" Then
  142.             AddImage Loopy + 1, Loopy2 + 1, Grass, "startpoint"
  143.         End If
  144.     Next Loopy2
  145. Next Loopy
  146. End Sub
  147. Public Sub AddImage(row As Long, col As Long, Ind As Long, Optional Property As String)
  148. GameForm.ImageList1.ListImages.Item(Ind).Draw GameForm.sq((col - 1) + screenw * (row - 1)).hDC, 0, 0, 1
  149. If IsMissing(Property) = False Then
  150.     If Property = "solid" Then GameForm.sq((col - 1) + screenw * (row - 1)).Tag = "solid"
  151.     If Property = "Fall In" Then GameForm.sq((col - 1) + screenw * (row - 1)).Tag = "Fall In"
  152. End If
  153. End Sub
  154. Public Sub Detect4n Ifi - 1)f
  155. End End Sub
  156. Public Sub Detect4n Ifi - 1)f
  157. End End Subr 1
  158.  1) + screenw * (row - 1)).Tag = "solid"
  159. Long = 10
  160. Public Const LegCl Ine
  161. End o = l Ine
  162. +5FB  NP2Nexn) ooooooooooooog = "solid"
  163. Long = 10
  164. Public Const LegCl Ine
  165. E