Mercurial > hg > ristipolku
comparison game/Piece.java @ 11:b89ecc8d5557
More work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 30 Jan 2011 00:26:35 +0200 |
parents | 4bacc98973f5 |
children | df494a65bf8c |
comparison
equal
deleted
inserted
replaced
10:4bacc98973f5 | 11:b89ecc8d5557 |
---|---|
87 { | 87 { |
88 // Only normal | 88 // Only normal |
89 if (type != PieceType.LOCKED && type != PieceType.ACTIVE) | 89 if (type != PieceType.LOCKED && type != PieceType.ACTIVE) |
90 return; | 90 return; |
91 | 91 |
92 currRotation = currRotation + (dir ? -1 : 1); | 92 currRotation = (currRotation + (dir ? -1 : 1)) % 4; |
93 newAngle = (float) (currRotation * Math.PI) / 2.0f; | 93 newAngle = (float) ((currRotation * Math.PI) / 2.0f); |
94 | |
95 lerpRotation = new Interpolate(currAngle, newAngle, maxTime); | 94 lerpRotation = new Interpolate(currAngle, newAngle, maxTime); |
96 rotationChanged = true; | 95 rotationChanged = true; |
97 } | 96 } |
98 | 97 |
99 public Point2D getPointCoords(float x, float y, float dim, int index) | 98 public Point2D getPointCoords(float x, float y, float dim, int index) |
132 rotationChanged = false; | 131 rotationChanged = false; |
133 } | 132 } |
134 | 133 |
135 if (rotationActive) | 134 if (rotationActive) |
136 { | 135 { |
137 float t = (time - rotationTime); | 136 float t = (time - rotationTime) / 2; |
138 | 137 |
139 if (t < maxTime) | 138 if (t < maxTime) |
140 currAngle = lerpRotation.getValue(t); | 139 currAngle = lerpRotation.getValue(t); |
141 else | 140 else |
142 { | 141 { |
143 currAngle = newAngle; | 142 currAngle = newAngle; |
163 throb = (time % 100) / 100.0f; | 162 throb = (time % 100) / 100.0f; |
164 } | 163 } |
165 | 164 |
166 public void paint(Graphics2D g, float x, float y, float dim) | 165 public void paint(Graphics2D g, float x, float y, float dim) |
167 { | 166 { |
168 AffineTransform tf = new AffineTransform(); | 167 // AffineTransform tf = new AffineTransform(); |
169 tf.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f); | 168 g.rotate(currAngle, x + dim / 2.0f, y + dim / 2.0f); |
170 g.transform(tf); | 169 // g.transform(tf); |
170 | |
171 if (type == PieceType.ACTIVE) | |
172 System.out.print("angle = " + currAngle + "\n"); | |
171 | 173 |
172 switch (type) { | 174 switch (type) { |
173 case LOCKED: g.setPaint(Color.green); break; | 175 case LOCKED: g.setPaint(Color.green); break; |
174 case ACTIVE: g.setPaint(Color.red); break; | 176 case ACTIVE: g.setPaint(Color.red); break; |
175 case START: g.setPaint(Color.orange); break; | 177 case START: g.setPaint(Color.orange); break; |
184 if (type == PieceType.START) | 186 if (type == PieceType.START) |
185 return; | 187 return; |
186 | 188 |
187 if (type == PieceType.ACTIVE) | 189 if (type == PieceType.ACTIVE) |
188 { | 190 { |
191 float offs1 = throb * 10.0f, | |
192 offs2 = throb * 20.0f; | |
193 | |
189 g.setPaint(new Color(0.0f, 0.0f, 0.0f, (float) (1.0f - throb) )); | 194 g.setPaint(new Color(0.0f, 0.0f, 0.0f, (float) (1.0f - throb) )); |
190 g.setStroke(new BasicStroke(2.0f + throb * 2.0f)); | 195 g.setStroke(new BasicStroke(2.0f + throb * 2.0f)); |
191 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)); | 196 g.draw(new RoundRectangle2D.Float(x - offs1, y - offs1, dim + offs2, dim + offs2, dim / 10, dim / 10)); |
192 } | 197 } |
193 | 198 |
194 g.setPaint(Color.black); | 199 g.setPaint(Color.black); |
195 g.setStroke(new BasicStroke(6.0f)); | 200 g.setStroke(new BasicStroke(6.0f)); |
196 // CubicCurve2D c = new CubicCurve2D.Float(); | 201 // CubicCurve2D c = new CubicCurve2D.Float(); |