-
Notifications
You must be signed in to change notification settings - Fork 1
/
Monstr.cls
256 lines (245 loc) · 9.65 KB
/
Monstr.cls
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Motion"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Dim imgX As ListImage
Private Declare Function BitBlt _
Lib "gdi32" ( _
ByVal hDestDC As Long, _
ByVal X As Long, ByVal ó 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
Dim lngW As Long, lngH As Long
Dim lnX As Long, lnY As Long
Dim lngRtn As Long
Sub AddMons(Personag As Integer, Name As String)
DoEvents
Dim intCount As Integer
On Error GoTo ExitSub
frmMon.Mon.Picture = LoadPicture(GameDir & "\Image\Personag\" & Name & "_" & Personag & "_0.gif")
For intCount = 0 To SetMajor
'çàãðóçêà êàðòèíîêè è ñîõðàíåíèå â imlPon
frmMon.Mon.Picture = LoadPicture(GameDir & "\Image\Personag\" & Name & "_" & Personag & "_" & intCount & ".gif")
frmMon.MonNeg.Picture = LoadPicture(GameDir & "\Image\Personag\NPersonag\" & Name & "_" & Personag & "_" & intCount & ".gif")
'äîá â íàáîð ïîçèòåâ
Set imgX = frmMon.imlMon.ListImages.Add(, , frmMon.Mon.Picture)
'äîá â íàáîð íåãàòèâ
Set imgX = frmMon.imlMon.ListImages.Add(, , frmMon.MonNeg.Picture)
'çàãðóçêà êàðòèíîêè è ñîõðàíåíèå
frmMon.Mon.Picture = LoadPicture(GameDir & "\Image\Personag\MPersonag\" & Name & "_" & Personag & "_" & intCount & ".gif")
frmMon.MonNeg.Picture = LoadPicture(GameDir & "\Image\Personag\NMPersonag\" & Name & "_" & Personag & "_" & intCount & ".gif")
'äîá â íàáîð ïîçèòåâ
Set imgX = frmMon.imlMon.ListImages.Add(, , frmMon.Mon.Picture)
'äîá â íàáîð íåãàòèâ
Set imgX = frmMon.imlMon.ListImages.Add(, , frmMon.MonNeg.Picture)
Next intCount
ExitSub:
lnX = frmMon.imlMon.ListImages.Count
End Sub
Private Sub Move(X As Single, Y As Single, Direction As String)
Dim XCorection As Integer
Dim Ycorection As Integer
' îïðåäåëåíèå íàïðàâëåíèÿ äâèæåíèÿ
If Direction = "up" Then XCorection = 1: Ycorection = -1
If Direction = "doun" Then XCorection = -1: Ycorection = 1
If Direction = "left" Then XCorection = -1: Ycorection = -1
If Direction = "right" Then XCorection = 1: Ycorection = 1
If Direction = "stand" Then XCorection = 0: Ycorection = 0
' ïåðåìåùàåì â íîâûé ó÷àñòîê
X = X + 4 * XCorection
Y = Y + 2 * Ycorection
End Sub
Public Sub Paint(Personag As Integer, X As Single, Y As Single, Position As Integer)
Dim intM As Integer, intN As Integer, mXp As Integer, mYp As Integer
Dim furX As Single, furY As Single
Dim Xstr As Integer, Ystr As Integer
Dim pPersonag As Integer
Map.DectoPlc X + 25, Y + 55, intN, intM
' öèêë àíèìàöèè
frmMon.MonNeg.Picture = frmMon.imlMon.ListImages.Item(Position + 1 + 48 * Personag).Picture
frmMon.Mon.Picture = frmMon.imlMon.ListImages.Item(Position + 48 * Personag).Picture
For mXp = intN - 2 To intN + 1
For mYp = intM + 1 To intM + 7
If mYp > 42 Or mXp > 15 Or mXp < 0 Then GoTo NextSearch
pPersonag = Place(mXp, mYp, 0)
If pPersonag > 15 And pPersonag < 255 Then ' ïîèñê ìåáåëè
Xstr = Place(mXp, mYp, 1)
Ystr = Place(mXp, mYp, 2)
If Xstr = mXp And Ystr = mYp Then
Map.PlstoDec mXp, mYp, furX, furY
furX = furX - 47 - X
furY = furY - 95 - Y
frmMon.FurnNeg.Picture = frmMon.imlFurn.ListImages.Item((pPersonag - 16) * 2 + 2).Picture
frmMon.Furn.Picture = frmMon.imlFurn.ListImages.Item((pPersonag - 16) * 2 + 1).Picture
' ïðèìåíÿåì ìàñêó äëÿ ìåáåëè
lngRtn = BitBlt(frmMon.Mon.hDC, furX, furY, 150, 185, frmMon.FurnNeg.hDC, 0, 0, vbSrcAnd)
' ðèñóåì
lngRtn = BitBlt(frmMon.Mon.hDC, furX, furY, 150, 185, frmMon.Furn.hDC, 0, 0, vbSrcPaint)
End If
End If
NextSearch:
Next mYp
Next mXp
' ïðèìåíÿåì ìàñêó
lngRtn = BitBlt(ServiseForm.hDC, X, Y, 50, 75, frmMon.MonNeg.hDC, 0, 0, vbSrcAnd)
' ðèñóåì
lngRtn = BitBlt(ServiseForm.hDC, X, Y, 50, 75, frmMon.Mon.hDC, 0, 0, vbSrcPaint)
End Sub
Public Sub Fps()
Dim lngRtn As Long
' ïðîðèñîâêà ïëèòêè è ìåáåëè
ServiseForm.Picture = ServiseForm.imlFon.ListImages.Item(1).Picture
For Xp = 0 To 15
For Yp = 6 To 42
Personag = Place(Xp, Yp, 0)
If Personag < 16 Then ' ïîèñê ïåðñîíàæåé
Paint Personag, X(Personag), Y(Personag), intPos(Personag)
End If
If Personag >= 27 And Personag <= 31 Then ' ïîèñê áîíóñîâ
Map.FurnPaint Xp, Yp, (Personag - 16) * 2 + 1
End If
Next Yp
Next Xp
End Sub
Public Function PersonagMove(Personag As Integer) As Byte
If intMaxPos(Personag) - intPos(Personag) = 21 Then
If Not (CheckingMove(Personag, X(Personag), Y(Personag), PersonagMove)) Then
blnMove(Personag) = False
strDir(Personag) = "stand"
Exit Function
Else
blnMove(Personag) = True
End If
End If
Move X(Personag), Y(Personag), strDir(Personag)
intPos(Personag) = intPos(Personag) + 4
If intPos(Personag) >= intMaxPos(Personag) Then
blnMove(Personag) = False
intPos(Personag) = intPos(Personag) - 4
strDir(Personag) = "stand"
End If
End Function
Public Sub MonstrsMove(NumPersonag As Integer)
Dim MMPersonag As Integer
For MMPersonag = 1 To NumPersonag
If strDir(MMPersonag) = "stand" Then MonsMove MMPersonag, X(MMPersonag), Y(MMPersonag)
If intMaxPos(MMPersonag) - intPos(MMPersonag) = 21 Then
If Not (CheckingMove(MMPersonag, X(MMPersonag), Y(MMPersonag), 0)) Then
blnMove(MMPersonag) = False
strDir(MMPersonag) = "stand"
GoTo EndPnt
Else
blnMove(MMPersonag) = True
End If
End If
Move X(MMPersonag), Y(MMPersonag), strDir(MMPersonag)
intPos(MMPersonag) = intPos(MMPersonag) + 4
If intPos(MMPersonag) >= intMaxPos(MMPersonag) Then
blnMove(MMPersonag) = False
intPos(MMPersonag) = intPos(MMPersonag) - 4
strDir(MMPersonag) = "stand"
End If
EndPnt:
Next MMPersonag
End Sub
Private Sub MonsMove(Personag As Integer, xs As Single, ys As Single)
Dim N As Integer
Dim Xstp As Integer, Ystp As Integer
Dim NumFurn As Integer
Catch = False
Map.DectoPlc xs + 25, ys + 55, Xstp, Ystp
'Îõîòà
For Xp = Xstp - SeeDistance(Personag) To Xstp + SeeDistance(Personag)
For Yp = Ystp - Personag To Ystp + Personag
If Xp < 0 Or Yp < 0 Or Xp > 15 Or Yp > 48 Then GoTo NextPos
NumFurn = Place(Xp, Yp, 0)
' ïîèñê 0 ïåðñîíàæà
If NumFurn = 0 Then
If Abs(Xstp - Xp) <= 1 And Abs(Ystp - Yp) <= 1 Then Catch = True
If Yp - Ystp < 0 And Xp - Xstp < 0 Then N = 1: GoTo Napr
If Yp - Ystp < 0 And Xp - Xstp > 0 Then N = 3: GoTo Napr
If Yp - Ystp > 0 And Xp - Xstp < 0 Then N = 2: GoTo Napr
If Yp - Ystp > 0 And Xp - Xstp > 0 Then N = 0: GoTo Napr
GoTo Napr
End If
NextPos:
Next Yp
Next Xp
'Áåñïîðÿäî÷íîå äâèæåíèå
Randomize Timer
N = Rnd * (20 + Personag \ 3)
Napr:
If N = 0 Then strDir(Personag) = "right": intPos(Personag) = 1: intMaxPos(Personag) = 22
If N = 1 Then strDir(Personag) = "left": intPos(Personag) = 27: intMaxPos(Personag) = 48
If N = 2 Then strDir(Personag) = "doun": intPos(Personag) = 3: intMaxPos(Personag) = 24
If N = 3 Then strDir(Personag) = "up": intPos(Personag) = 25: intMaxPos(Personag) = 46
If N = 4 Then strDir(Personag) = "stand": intPos(Personag) = intPos(Personag) - 4: intMaxPos(Personag) = 22
End Sub
Private Function CheckingMove(Personag As Integer, X As Single, Y As Single, Bonus As Byte) As Boolean
Dim XCorection As Integer
Dim Ycorection As Integer
' óáèðàíèå ìåñòà ïîëîæåíèÿ ïåðñîíàæà
Map.DectoPlc X + 25, Y + 55, Xp, Yp
Place(Xp, Yp, 0) = 255
' îïðåäåëåíèå íàïðàâëåíèÿ äâèæåíèÿ
If strDir(Personag) = "up" Then XCorection = 1: Ycorection = -1
If strDir(Personag) = "doun" Then XCorection = -1: Ycorection = 1
If strDir(Personag) = "left" Then XCorection = -1: Ycorection = -1
If strDir(Personag) = "right" Then XCorection = 1: Ycorection = 1
If strDir(Personag) = "stand" Then XCorection = 0: Ycorection = 0
' ïåðåâîä èç äåêàðòîâîé ñèñ.
Map.DectoPlc X + 27 + 24 * XCorection, Y + 55 + 12 * Ycorection, Xp, Yp
If Place(Xp, Yp, 0) < 16 Or Place(Xp, Yp, 0) > 31 And Place(Xp, Yp, 0) < 255 Or Place(Xp, Yp, 3) = 0 Or Personag <> 0 And Place(Xp, Yp, 0) > 26 And Place(Xp, Yp, 0) < 255 Then
ExitSub:
CheckingMove = False
' óñòàíîâêà ïîëîæåíèÿ ïåðñîíàæà
Map.DectoPlc X + 27, Y + 55, Xp, Yp
Place(Xp, Yp, 0) = Personag
Bonus = 0
Else
CheckingMove = True
' óñòàíîâêà ïîëîæåíèÿ ïåðñîíàæà
Bonus = Place(Xp, Yp, 0)
Place(Xp, Yp, 0) = Personag
End If
End Function
Sub KeyPress(Personag As Integer, KeyCode As Integer, Shift As Integer)
If blnMove(Personag) Then Exit Sub
If KeyCode = 83 Then
strDir(Personag) = "right"
intPos(Personag) = 1
intMaxPos(Personag) = 22
blnMove(Personag) = True
End If
If KeyCode = 65 Then
strDir(Personag) = "doun"
intPos(Personag) = 3
intMaxPos(Personag) = 24
blnMove(Personag) = True
End If
If KeyCode = 87 Then
strDir(Personag) = "up"
intPos(Personag) = 25
intMaxPos(Personag) = 46
blnMove(Personag) = True
End If
If KeyCode = 81 Then
strDir(Personag) = "left"
intPos(Personag) = 27
intMaxPos(Personag) = 48
blnMove(Personag) = True
End If
End Sub