-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.bi
68 lines (49 loc) · 1.18 KB
/
map.bi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
' Manage map data
'
' Represents a 1x1 segment of the map
Type mapSegment
solid As Byte
textureID As Integer
End Type
' The map
type gameMap
mapW As Integer
mapH As Integer
segment ( Any, Any ) As mapSegment
Declare Constructor ( ByVal As Integer, ByVal As Integer )
Declare Sub load ( ByVal As String )
Declare Sub save ( ByVal As String )
end type
Constructor gameMap ( ByVal w As Integer, ByVal h As Integer )
' Size the array
ReDim this.segment( w, h ) As mapSegment
this.mapW = w
this.mapH = h
End Constructor
Sub gameMap.load( ByVal fname As String )
' Load the data from a file
Dim As Integer hndl = FreeFile
Open fname For Binary As #hndl
Get #hndl,, mapW
Get #hndl,, mapH
ReDim this.segment( mapW, mapH ) As mapSegment
For y As Integer = 0 to mapH
For x As Integer = 0 to mapW
Get #hndl,, this.segment( x, y )
Next
Next
Close #hndl
End Sub
Sub gameMap.save( ByVal fname As String )
' Save the data to a file
Dim As Integer hndl = FreeFile
Open fname For Binary As #hndl
Put #hndl,, mapW
Put #hndl,, mapH
For y As Integer = 0 to mapH
For x As Integer = 0 to mapW
Put #hndl,, this.segment( x, y )
Next
Next
Close #hndl
End Sub