1
+ #include once "modules/inc/dart.bi"
2
+
3
+ property Dart.way() as Vector
4
+ 'return this._way
5
+ return Vector(this._vx, this._vy)
6
+ end property
7
+ property Dart.way(new_way as Vector)
8
+ 'this._way = new_way
9
+ this._vx = new_way.x
10
+ this._vy = new_way.y
11
+ end property
12
+ property Dart.position() as Vector
13
+ 'return this._position
14
+ return Vector(this._x, this._y)
15
+ end property
16
+ property Dart.position(new_position as Vector)
17
+ 'this._position = new_position
18
+ this._x = new_position.x
19
+ this._y = new_position.y
20
+ end property
21
+ property Dart.speed() as double
22
+ return this._speed
23
+ end property
24
+ property Dart.speed(new_speed as double )
25
+ this._speed = new_speed
26
+ end property
27
+
28
+ function Dart.getIndexId() as integer
29
+ return this._index_id
30
+ end function
31
+ function Dart.setIndexId(id as integer ) as Dart ptr
32
+ this._index_id = id
33
+ return @this
34
+ end function
35
+ function Dart.getIncrementId() as integer
36
+ return this._increment_id
37
+ end function
38
+ function Dart.setIncrementId(id as integer ) as Dart ptr
39
+ this._increment_id = id
40
+ return @this
41
+ end function
42
+ function Dart.getOwnerId() as integer
43
+ return this._owner_id
44
+ end function
45
+ function Dart.setOwnerId(owner_id as integer ) as Dart ptr
46
+ this._owner_id = owner_id
47
+ return @this
48
+ end function
49
+ function Dart.getX() as double
50
+ return this._x
51
+ end function
52
+ function Dart.setX(x as double ) as Dart ptr
53
+ this._x = x
54
+ return @this
55
+ end function
56
+ function Dart.getY() as double
57
+ return this._y
58
+ end function
59
+ function Dart.setY(y as double ) as Dart ptr
60
+ this._y = y
61
+ return @this
62
+ end function
63
+ function Dart.getZ() as double
64
+ return this._z
65
+ end function
66
+ function Dart.setZ(z as double ) as Dart ptr
67
+ this._z = z
68
+ return @this
69
+ end function
70
+ function Dart.setXYZ(x as double , y as double , z as double ) as Dart ptr
71
+ this._x = x
72
+ this._y = y
73
+ this._z = z
74
+ return @this
75
+ end function
76
+ function Dart.getVx() as double
77
+ return this._vx
78
+ end function
79
+ function Dart.setVx(vx as double ) as Dart ptr
80
+ this._vx = vx
81
+ return @this
82
+ end function
83
+ function Dart.getVy() as double
84
+ return this._vy
85
+ end function
86
+ function Dart.setVy(vy as double ) as Dart ptr
87
+ this._vy = vy
88
+ return @this
89
+ end function
90
+ function Dart.getVz() as double
91
+ return this._vz
92
+ end function
93
+ function Dart.setVz(vz as double ) as Dart ptr
94
+ this._vz = vz
95
+ return @this
96
+ end function
97
+ function Dart.setVxVyVz(vx as double , vy as double , vz as double ) as Dart ptr
98
+ this._vx = vx
99
+ this._vy = vy
100
+ this._vz = vz
101
+ return @this
102
+ end function
103
+ function Dart.getStartX() as double
104
+ return this._startX
105
+ end function
106
+ function Dart.setStartX(x as double ) as Dart ptr
107
+ this._startX = x
108
+ return @this
109
+ end function
110
+ function Dart.getStartY() as double
111
+ return this._startY
112
+ end function
113
+ function Dart.setStartY(y as double ) as Dart ptr
114
+ this._startX = y
115
+ return @this
116
+ end function
117
+ function Dart.getStartZ() as double
118
+ return this._startZ
119
+ end function
120
+ function Dart.setStartZ(z as double ) as Dart ptr
121
+ this._startZ = z
122
+ return @this
123
+ end function
124
+ function Dart.setStartXYZ(x as double , y as double , z as double ) as Dart ptr
125
+ this._startX = x
126
+ this._startY = y
127
+ this._startZ = z
128
+ return @this
129
+ end function
130
+ function Dart.getAngle() as double
131
+ return this._ang
132
+ end function
133
+ function Dart.setAngle(ang as double ) as Dart ptr
134
+ this._ang = ang
135
+ return @this
136
+ end function
137
+ function Dart.hasClip() as integer
138
+ return (this._clipVx <> 0 or this._clipVy <> 0 or this._clipVz <> 0 )
139
+ end function
140
+ function Dart.clearClip() as Dart ptr
141
+ this._clipVx = 0
142
+ this._clipVy = 0
143
+ this._clipVz = 0
144
+ this._clipStepX = 0
145
+ this._clipStepY = 0
146
+ this._clipStepZ = 0
147
+ return @this
148
+ end function
149
+ function Dart.getSpeed() as double
150
+ return this._speed
151
+ end function
152
+ function Dart.setSpeed(dart_speed as double ) as Dart ptr
153
+ this._speed = dart_speed
154
+ return @this
155
+ end function
156
+ function Dart.getCount() as double
157
+ return this._count
158
+ end function
159
+ function Dart.setCount(count as double ) as Dart ptr
160
+ this._count = count
161
+ return @this
162
+ end function
163
+ function Dart.setMoveCallback(p as sub (d as Dart ptr, t as double )) as Dart ptr
164
+ this._move_callback = p
165
+ return @this
166
+ end function
167
+ function Dart.move(t as double ) as Dart ptr
168
+ if this._move_callback <> 0 then
169
+ this._move_callback( @this, t)
170
+ else
171
+ this.moveOrthogonal(t)
172
+ 'this._x += this._vx*this._speed*t
173
+ 'this._y += this._vy*this._speed*t
174
+ end if
175
+ return @this
176
+ end function
177
+ sub Dart.moveOrthogonal(t as double )
178
+ dim dx as double , dy as double , dz as double
179
+ dim x as double , y as double , z as double
180
+ if this.hasClip() then
181
+ if abs(this._clipVx) > 0 then
182
+ if abs(this._clipVx) > abs(this._clipStepX) then
183
+ dx = this._clipStepX
184
+ this._clipVx -= this._clipStepX
185
+ else
186
+ dx = this._clipVx
187
+ this._clipVx = 0
188
+ end if
189
+ elseif abs(this._clipVy) > 0 then
190
+ if abs(this._clipVy) > abs(this._clipStepY) then
191
+ dy = this._clipStepY
192
+ this._clipVy -= this._clipStepY
193
+ else
194
+ dy = this._clipVy
195
+ this._clipVy = 0
196
+ end if
197
+ elseif abs(this._clipVz) > 0 then
198
+ if abs(this._clipVz) > abs(this._clipStepZ) then
199
+ dz = this._clipStepZ
200
+ this._clipVz -= this._clipStepZ
201
+ else
202
+ dz = this._clipVz
203
+ this._clipVz = 0
204
+ end if
205
+ end if
206
+ else
207
+ dx = this._vx*this._speed*t
208
+ dy = this._vy*this._speed*t
209
+ dz = this._vz*this._speed*t
210
+ if abs(dx) > 1 then
211
+ x = dx / (int(abs(dx))+ 1 )
212
+ this._clipVx = dx - x
213
+ this._clipStepX = x
214
+ dx = x
215
+ elseif abs(dy) > 1 then
216
+ y = dy / (int(abs(dy))+ 1 )
217
+ this._clipVy = dy - y
218
+ dy = y
219
+ this._clipStepY = y
220
+ elseif abs(dz) > 1 then
221
+ z = dz / (int(abs(dz))+ 1 )
222
+ this._clipVz = dz - z
223
+ dz = z
224
+ this._clipStepZ = z
225
+ end if
226
+ end if
227
+ this._x += dx
228
+ this._y += dy
229
+ this._z += dz
230
+ end sub
231
+ function Dart.setCollideCallback(p as function (x as double , y as double , z as double ) as integer ) as Dart ptr
232
+ this._collide_callback = p
233
+ return @this
234
+ end function
235
+ function Dart.collide() as integer
236
+ return this._collide_callback(this._x+ 0.5 , this._y+ 0 . 5 , this._z+ 0 . 5 )
237
+ end function
238
+ function Dart.setBeforeDelete(p as sub (d as Dart ptr)) as Dart ptr
239
+ this._before_delete = p
240
+ return @this
241
+ end function
242
+ function Dart.callBeforeDelete() as Dart ptr
243
+ if this._before_delete <> 0 then
244
+ this._before_delete( @this)
245
+ end if
246
+ return @this
247
+ end function
248
+ function Dart.getExpires() as integer
249
+ return this._expires
250
+ end function
251
+ function Dart.setExpires(expires as integer ) as Dart ptr
252
+ this._expires = expires
253
+ return @this
254
+ end function
255
+ function Dart.getExpiresInSeconds() as double
256
+ return this._expires_in_seconds
257
+ end function
258
+ function Dart.setExpiresInSeconds(seconds as double ) as Dart ptr
259
+ this._expires_in_seconds = seconds
260
+ return @this
261
+ end function
262
+ function Dart.getDamage() as double
263
+ return this._damage
264
+ end function
265
+ function Dart.setDamage(damage as double ) as Dart ptr
266
+ this._damage = damage
267
+ return @this
268
+ end function
269
+ function Dart.getDamageType() as integer
270
+ return this._damage_type
271
+ end function
272
+ function Dart.setDamageType(damage_type as integer ) as Dart ptr
273
+ this._damage_type = damage_type
274
+ return @this
275
+ end function
276
+ function Dart.getFrames() as integer
277
+ return this._frames
278
+ end function
279
+ function Dart.setFrames(frames as integer ) as Dart ptr
280
+ this._frames = frames
281
+ return @this
282
+ end function
283
+ function Dart.getFrameStart() as integer
284
+ return this._frame_start
285
+ end function
286
+ function Dart.setFrameStart(frame_start as integer ) as Dart ptr
287
+ this._frame_start = frame_start
288
+ return @this
289
+ end function
290
+ function Dart.getFrameSpeed() as double
291
+ return this._frame_speed
292
+ end function
293
+ function Dart.setFrameSpeed(frame_speed as double ) as Dart ptr
294
+ this._frame_speed = frame_speed
295
+ return @this
296
+ end function
297
+ function Dart.expire() as Dart ptr
298
+ this._expires = 1
299
+ this._count = this._frames
300
+ return @this
301
+ end function
302
+ function Dart.expireSeconds(seconds as double ) as integer
303
+ this._expires_in_seconds -= seconds
304
+ if this._expires_in_seconds <= 0 then
305
+ this._expires_in_seconds = 0
306
+ return 1
307
+ end if
308
+ return 0
309
+ end function
310
+ function Dart.setFlag(flag as integer ) as Dart ptr
311
+ this._flags = (this._flags or flag)
312
+ return @this
313
+ end function
314
+ function Dart.hasFlag(flag as integer ) as integer
315
+ return iif((this._flags and flag) > 0 , 1 , 0 )
316
+ end function
317
+ function Dart.clearFlag(flag as integer ) as Dart ptr
318
+ this._flags = (this._flags or flag) xor flag
319
+ return @this
320
+ end function
321
+ function Dart.clearAllFlags() as Dart ptr
322
+ this._flags = 0
323
+ return @this
324
+ end function
325
+ function Dart.setRenderCallback(p as sub (d as Dart ptr)) as Dart ptr
326
+ this._render_callback = p
327
+ return @this
328
+ end function
329
+ function Dart.render() as Dart ptr
330
+ this._render_callback( @this)
331
+ return @this
332
+ end function
0 commit comments