-
Notifications
You must be signed in to change notification settings - Fork 2
/
DPATH.SC
78 lines (60 loc) · 1.31 KB
/
DPATH.SC
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
;;;; DPATH.SC (c) Sierra On-Line, Inc, 1989
;;;;
;;;; Author: Pablo Ghenis
;;;;
;;;; D(ynamic)PATH uses a dynamically created list to keep path
;;;; points.
;;;;
;;;; Usage is like other motion classes:
;;;;
;;;; (anActor setMotion DPath x1 y1 x2 y2 ... anOptionalCaller)
;;;;
;;;; (also see PATH.SC for static path class)
;;;;
(script# DPATH)
(class DPath of Motion
(properties
points NULL ;dynamic list to hold path points
value 0 ;index into path array
)
(method (init theClient thePoints &tmp i)
(= points (or points (List new))) ;create only once
(if argc
(= client theClient)
(for
((= i 0))
(<= i (- argc 3))
((++ i))
(points add [thePoints i] [thePoints (++ i)])
)
;final odd argument, if present, is caller
(if (<= i (- argc 2))
(= caller [thePoints i])
)
)
(or
(points contains PATHEND)
(points add PATHEND) ;terminate only once
)
(self setTarget)
(super init)
)
(method (dispose)
(if (IsObject points) (points dispose))
(super dispose)
)
(method (setTarget)
(if (!= (points at value) PATHEND)
(= x (points at value))
(= y (points at (++ value)))
(++ value)
)
)
(method (moveDone)
(if (== (points at value) PATHEND)
(super moveDone)
else
(self init)
)
)
);DPath