Mercurial > hg > ristipolku
comparison game/Piece.java @ 54:cc7943cd7f2d
Moar work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 23 Feb 2011 19:54:48 +0200 |
parents | 79185dababf2 |
children | cde170f2f980 |
comparison
equal
deleted
inserted
replaced
53:6bf4675e2d96 | 54:cc7943cd7f2d |
---|---|
23 PieceType type, prevType; | 23 PieceType type, prevType; |
24 | 24 |
25 boolean rotationChanged, rotationActive, | 25 boolean rotationChanged, rotationActive, |
26 typeChanged, typeActive, | 26 typeChanged, typeActive, |
27 stateChanged, stateActive; | 27 stateChanged, stateActive; |
28 float currAngle, newAngle, rotationTime, typeTime; | 28 float currAngle, newAngle, rotationTime, typeTime, rotationSpeed; |
29 | 29 |
30 float throbTime; | 30 float throbTime; |
31 Interpolate lerpRotation; | 31 Interpolate lerpRotation; |
32 | 32 |
33 | 33 |
193 if (rotationChanged) | 193 if (rotationChanged) |
194 { | 194 { |
195 rotationTime = time; | 195 rotationTime = time; |
196 rotationActive = true; | 196 rotationActive = true; |
197 rotationChanged = false; | 197 rotationChanged = false; |
198 rotationSpeed = 0.5f; | |
199 } | |
200 | |
201 if (typeChanged && type == PieceType.LOCKED) | |
202 { | |
203 rotationSpeed = 1.0f; | |
198 } | 204 } |
199 | 205 |
200 if (rotationActive) | 206 if (rotationActive) |
201 { | 207 { |
202 float t = (time - rotationTime) / 2; | 208 float t = (time - rotationTime) * rotationSpeed; |
203 | 209 |
204 if (t < maxTime) | 210 if (t < maxTime) |
205 currAngle = lerpRotation.getValue(t); | 211 currAngle = lerpRotation.getValue(t); |
206 else | 212 else |
207 { | 213 { |
208 currAngle = newAngle; | 214 currAngle = newAngle; |
209 rotationActive = false; | 215 rotationActive = false; |
210 } | 216 } |
211 } | 217 } |
212 | 218 |
213 if (typeChanged) | 219 if (typeChanged) |
214 { | 220 { |
215 typeTime = time; | 221 typeTime = time; |
216 typeActive = true; | 222 typeActive = true; |
217 typeChanged = false; | 223 typeChanged = false; |
222 } | 228 } |
223 | 229 |
224 if (stateChanged) | 230 if (stateChanged) |
225 { | 231 { |
226 } | 232 } |
233 | |
234 | |
227 | 235 |
228 throbTime = (time % 100) / 100.0f; | 236 throbTime = (time % 100) / 100.0f; |
229 } | 237 } |
230 | 238 |
231 public void paint(Graphics2D g, float x, float y, float dim) | 239 public void paint(Graphics2D g, float x, float y, float dim) |