-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mine.bb
152 lines (119 loc) · 3.04 KB
/
Mine.bb
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
Type MINE
Field X
Field Y
End Type
Const MINE_SIZE#=1.0
Const MINE_Y_OFFSET#=0.1
Const MINE_COLOUR_RED=-65536
Const MINE_COLOUR_YELLOW=-256
Global MINE_MASTER
Global MINE_MAT
Global MINE_MAT_UPDATE_DURATION=500
Global MINE_MAT_UPDATE_LAST
Global MINE_SWITCH
Function UnInitialiseMineFiles()
If (TEST) Then Return
; DeleteFile MineAnimFile()
DeleteFile MineMatFile()
End Function
Function InitialiseMineFiles()
;UnPackAsset(PACK_MINE_ANIM_START,PACK_MINE_ANIM_LENGTH)
UnPackAsset(PACK_MINE_MAT_START,PACK_MINE_MAT_LENGTH)
End Function
;Function MineAnimFile$()
; Return AnimFile(MINE_FILE)
;End Function
Function MineMatFile$()
Return MatFile(MAP_MINE_NAME)
End Function
Function BuildMineMaster()
If (MINE_MASTER)
RemoveMines
End If
InitialiseMineFiles
MINE_MASTER=CreateMesh()
Local Surface=CreateSurface(MINE_MASTER)
If (Not(MINE_MAT))
MINE_MAT=SetMineMatAnimation()
End If
UnInitialiseMineFiles
PositionEntity MINE_MASTER,0,0,0,True
End Function
Function SpawnMine(X,Z)
Local M.MINE=New MINE
M\X=X
M\Y=Z
AddMineGeometry(M)
GhostMine(M)
End Function
Function FinaliseMines()
NameEntity MINE_MASTER,MAP_MINE_NAME
End Function
Function AddMineGeometry(M.MINE)
Local Mesh=CreateQuad()
ScaleMesh Mesh,MINE_SIZE,MINE_SIZE,0.01
RotateMesh Mesh,90,0,0
AddMeshToSurface(Mesh,MINE_MASTER,M\X-0.5,GROUND_BASELINE_Y+MINE_Y_OFFSET,M\Y-0.5)
FreeEntity Mesh
End Function
Function SetMineMatAnimation()
Local Texture
If (SPECTRUM_MODE)
Texture=CreateTexture(4,4,257,2)
Local B1=TextureBuffer(Texture,0)
Local B2=TextureBuffer(Texture,1)
LockBuffer B1
LockBuffer B2
Local X
Local Y
For Y=0 To 3
For X=0 To 3
If (((X Mod 3)<>0) And ((Y Mod 3)<>0))
WritePixelFast X,Y,MINE_COLOUR_RED,B1
WritePixelFast X,Y,MINE_COLOUR_YELLOW,B2
Else
WritePixelFast X,Y,MINE_COLOUR_YELLOW,B1
WritePixelFast X,Y,MINE_COLOUR_RED,B2
End If
Next
Next
UnlockBuffer B2
UnlockBuffer B1
Else
Texture=AcquireAnimTextureMap(MineMatFile())
End If
Return Texture
End Function
Function UpdateMines()
If ((MilliSecs()-MINE_MAT_UPDATE_LAST)>MINE_MAT_UPDATE_DURATION)
MINE_MAT_UPDATE_LAST=MilliSecs()
MINE_SWITCH=Not MINE_SWITCH
PaintMine()
End If
End Function
Function CheckLastKillerMine(X,Z)
Return (X=LAST_KILLER_MINEX) And (Z=LAST_KILLER_MINEY)
End Function
Function SetLastKillerMine(X,Z)
LAST_KILLER_MINEX=X
LAST_KILLER_MINEY=Z
End Function
Function ResetLastKillerMine()
SetLastKillerMine(9999,9999)
End Function
Function MineExplosion()
Debuglog("BOOM! : Mine_MineExplosion method called")
End Function
Function PaintMine()
EntityTexture MINE_MASTER,MINE_MAT,MINE_SWITCH
EntityFX MINE_MASTER,MINE_SWITCH
End Function
Function RemoveMines()
Local Surface=GetSurface(MINE_MASTER,1)
ClearSurface Surface,True,True
; FreeEntity MINE_MASTER
; MINE_MASTER=0
End Function
;~IDEal Editor Parameters:
;~F#0#11#18#25#38#40#44#4C#89#8E
;~C#Blitz3D