changeset 11:b89ecc8d5557

More work.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 30 Jan 2011 00:26:35 +0200
parents 4bacc98973f5
children c4cd811813ef
files game/Engine.java game/Piece.java
diffstat 2 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/game/Engine.java	Sat Jan 29 01:54:28 2011 +0200
+++ b/game/Engine.java	Sun Jan 30 00:26:35 2011 +0200
@@ -80,8 +80,6 @@
     Piece current;
     public boolean flagGameOver;
     
-    
-    
     int moveX, moveY, movePoint;
 
     public GameBoard()
--- a/game/Piece.java	Sat Jan 29 01:54:28 2011 +0200
+++ b/game/Piece.java	Sun Jan 30 00:26:35 2011 +0200
@@ -89,9 +89,8 @@
         if (type != PieceType.LOCKED && type != PieceType.ACTIVE)
             return;
 
-        currRotation = currRotation + (dir ? -1 : 1);
-        newAngle = (float) (currRotation * Math.PI) / 2.0f;
-
+        currRotation = (currRotation + (dir ? -1 : 1)) % 4;
+        newAngle = (float) ((currRotation * Math.PI) / 2.0f);
         lerpRotation = new Interpolate(currAngle, newAngle, maxTime);
         rotationChanged = true;
     }
@@ -134,8 +133,8 @@
 
         if (rotationActive)
         {
-            float t = (time - rotationTime);
-            
+            float t = (time - rotationTime) / 2;
+
             if (t < maxTime)
                 currAngle = lerpRotation.getValue(t);
             else
@@ -165,9 +164,12 @@
 
     public void paint(Graphics2D g, float x, float y, float dim)
     {
-        AffineTransform tf = new AffineTransform();
-        tf.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f);
-        g.transform(tf);
+//        AffineTransform tf = new AffineTransform();
+        g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f);
+//        g.transform(tf);
+
+        if (type == PieceType.ACTIVE)
+            System.out.print("angle = " + currAngle + "\n");
 
         switch (type) {
             case LOCKED:  g.setPaint(Color.green); break;
@@ -186,9 +188,12 @@
 
         if (type == PieceType.ACTIVE)
         {
+            float offs1 = throb * 10.0f,
+                  offs2 = throb * 20.0f;
+
             g.setPaint(new Color(0.0f, 0.0f, 0.0f, (float) (1.0f - throb) ));
             g.setStroke(new BasicStroke(2.0f + throb * 2.0f));
-            g.draw(new RoundRectangle2D.Float(x - throb * 10.0f, y - throb * 10.0f, dim + throb * 20.0f, dim + throb * 20.0f, dim / 10, dim / 10));
+            g.draw(new RoundRectangle2D.Float(x - offs1, y - offs1, dim + offs2, dim + offs2, dim / 10, dim / 10));
         }
 
         g.setPaint(Color.black);