Lines 6-11
Link Here
|
6 |
module abagames.ttn.pillar; |
6 |
module abagames.ttn.pillar; |
7 |
|
7 |
|
8 |
private import std.math; |
8 |
private import std.math; |
|
|
9 |
private import abagames.util.vector; |
9 |
private import abagames.util.actor; |
10 |
private import abagames.util.actor; |
10 |
private import abagames.ttn.field; |
11 |
private import abagames.ttn.field; |
11 |
private import abagames.ttn.token; |
12 |
private import abagames.ttn.token; |
Lines 38-44
Link Here
|
38 |
} |
39 |
} |
39 |
} |
40 |
} |
40 |
|
41 |
|
41 |
public class Pillar: Token!(PillarState, PillarSpec) { |
42 |
public class Token2(ST, SP): Actor { |
|
|
43 |
protected: |
44 |
ST state; |
45 |
SP spec; |
46 |
|
47 |
public void init(Object[] args) { |
48 |
state = new ST; |
49 |
} |
50 |
|
51 |
public void set(SP spec, Vector pos, float deg, float speed) { |
52 |
set(spec, pos.x, pos.y, deg, speed); |
53 |
} |
54 |
|
55 |
public void set(SP spec, float x, float y, float deg, float speed) { |
56 |
this.spec = spec; |
57 |
set(x, y, deg, speed); |
58 |
} |
59 |
|
60 |
public void set(float x, float y, float deg, float speed) { |
61 |
state.clear(); |
62 |
state.pos.x = x; |
63 |
state.pos.y = y; |
64 |
state.deg = deg; |
65 |
state.speed = speed; |
66 |
spec.set(state); |
67 |
_exists = true; |
68 |
} |
69 |
|
70 |
public void move() { |
71 |
if (!spec.move(state)) |
72 |
remove(); |
73 |
} |
74 |
|
75 |
public void remove() { |
76 |
_exists = false; |
77 |
spec.removed(state); |
78 |
} |
79 |
|
80 |
public void draw() { |
81 |
spec.draw(state); |
82 |
} |
83 |
|
84 |
public Vector pos() { |
85 |
return state.pos; |
86 |
} |
87 |
} |
88 |
|
89 |
public class Pillar: Token2!(PillarState, PillarSpec) { |
42 |
private: |
90 |
private: |
43 |
|
91 |
|
44 |
public void set(PillarSpec ps, float y, float maxY, Pillar pp, PillarShape s, float vdeg, bool outside = false) { |
92 |
public void set(PillarSpec ps, float y, float maxY, Pillar pp, PillarShape s, float vdeg, bool outside = false) { |
Lines 83-89
Link Here
|
83 |
} |
131 |
} |
84 |
} |
132 |
} |
85 |
|
133 |
|
86 |
public class PillarSpec:TokenSpec!(PillarState) { |
134 |
public class TokenSpec2(T) { |
|
|
135 |
protected: |
136 |
Field field; |
137 |
Shape shape; |
138 |
|
139 |
public void set(T state) {} |
140 |
public void removed(T state) {} |
141 |
|
142 |
public bool move(T state) { |
143 |
return true; |
144 |
} |
145 |
|
146 |
public void draw(T state) { |
147 |
with (state) { |
148 |
Vector3 p = field.calcCircularPos(pos); |
149 |
float cd = field.calcCircularDeg(pos.x); |
150 |
shape.draw(p, cd, deg); |
151 |
} |
152 |
} |
153 |
} |
154 |
|
155 |
public class PillarSpec:TokenSpec2!(PillarState) { |
87 |
private: |
156 |
private: |
88 |
static const VELOCITY_Y = 0.025f; |
157 |
static const VELOCITY_Y = 0.025f; |
89 |
|
158 |
|