comparison game/Piece.java @ 152:64b04c0eccce

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 06 Feb 2013 10:24:47 +0200
parents d6d92845d6a2
children 71205451ef57
comparison
equal deleted inserted replaced
151:d6d92845d6a2 152:64b04c0eccce
237 currScale = (float) (1.0 + Math.sin(lerpScale.getValue(t)) * 0.25); 237 currScale = (float) (1.0 + Math.sin(lerpScale.getValue(t)) * 0.25);
238 } 238 }
239 else 239 else
240 { 240 {
241 currAngle = lerpRotation.start; 241 currAngle = lerpRotation.start;
242 currScale = 1;
242 rotationActive = false; 243 rotationActive = false;
243 } 244 }
244 245
245 active = true; 246 active = true;
246 } 247 }
255 if (typeActive) 256 if (typeActive)
256 { 257 {
257 float t = (time - typeTime) * 2.0f; 258 float t = (time - typeTime) * 2.0f;
258 259
259 if (t < maxTime) 260 if (t < maxTime)
261 {
260 typeValue = lerpType.getValue(t); 262 typeValue = lerpType.getValue(t);
263 if (!rotationActive)
264 currScale = (float) (1.0 + Math.sin(lerpScale.getValue(t)) * 0.1);
265 }
261 else 266 else
262 { 267 {
263 typeValue = lerpType.start; 268 typeValue = lerpType.start;
269 if (!rotationActive)
270 currScale = 1;
264 typeActive = false; 271 typeActive = false;
265 } 272 }
266 273
267 274
268 active = true; 275 active = true;
278 public void paint(Graphics2D g, float x, float y, float dim) 285 public void paint(Graphics2D g, float x, float y, float dim)
279 { 286 {
280 AffineTransform save = g.getTransform(); 287 AffineTransform save = g.getTransform();
281 Composite csave = g.getComposite(); 288 Composite csave = g.getComposite();
282 289
283 // Scale dimensions
284 dim = dim * currScale;
285 290
286 // Change compositing alpha for the whole piece drawing 291 // Change compositing alpha for the whole piece drawing
287 // when the piece is being "introduced". 292 // when the piece is being "introduced".
288 if (typeActive) 293 if (typeActive)
289 { 294 {
291 } 296 }
292 297
293 298
294 // Transform drawing by current angle 299 // Transform drawing by current angle
295 g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f); 300 g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f);
301
302 // Scale dimensions
303 dim = dim * currScale;
296 304
297 // Color piece by type 305 // Color piece by type
298 switch (type) { 306 switch (type) {
299 case LOCKED: g.setPaint(new Color(0.3f, 0.8f, 0.3f, 0.35f)); break; 307 case LOCKED: g.setPaint(new Color(0.3f, 0.8f, 0.3f, 0.35f)); break;
300 case ACTIVE: g.setPaint(new Color(0.9f, 0.3f, 0.3f, 0.35f)); break; 308 case ACTIVE: g.setPaint(new Color(0.9f, 0.3f, 0.3f, 0.35f)); break;