Permalink
Browse files

Tweak the bounce code to compare to the shuttlecocks position in the …

…previous frame, which yields much better results.
  • Loading branch information...
1 parent def40d0 commit 7477715b34c7b6edb47e2b727212ddd5eae147bb @djcsdy committed Feb 12, 2012
@@ -91,7 +91,7 @@ package net.noiseinstitute.battledore_and_shuttlecock {
updateScore(score+1);
- if (shuttlecock.x > battledore.prevX) {
+ if (shuttlecock.prevX > battledore.prevX) {
if (shuttlecock.x < battledore.x + (shuttlecock.width + battledore.battledoreWidth) * 0.5 + 1) {
shuttlecock.x = battledore.x + (shuttlecock.width + battledore.battledoreWidth) * 0.5 + 1;
}
@@ -7,6 +7,9 @@ package net.noiseinstitute.battledore_and_shuttlecock {
public class Shuttlecock extends Entity {
private static const GRAVITY:Number = 0.1;
+ public var prevX:Number = 0;
+ public var prevY:Number = 0;
+
public var velocity:Point = new Point;
public function Shuttlecock() {
@@ -18,6 +21,9 @@ package net.noiseinstitute.battledore_and_shuttlecock {
}
override public function update():void {
+ prevX = x;
+ prevY = y;
+
velocity.y += GRAVITY;
x += velocity.x;

0 comments on commit 7477715

Please sign in to comment.