-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2155827
commit ed86a16
Showing
7 changed files
with
216 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Created by andrey on 26.06.2016. | ||
*/ | ||
package com.pinball.data | ||
{ | ||
public class GameStatics | ||
{ | ||
public static var GAME_WIDTH:Number; | ||
public static var GAME_HEIGHT:Number; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,11 @@ package com.pinball.ui.controls | |
addChild(shape); | ||
} | ||
|
||
|
||
public function get radius():Number | ||
{ | ||
return _radius; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Created by andrey on 25.06.2016. | ||
*/ | ||
package com.pinball.utils | ||
{ | ||
import flash.geom.Point; | ||
|
||
public class Vector2dUtils | ||
{ | ||
public function Vector2dUtils() | ||
{ | ||
} | ||
|
||
// find new vector bouncing from v2 | ||
public static function getBounceVector(ball:Point, dx:Number, dy:Number, lx:Number, ly:Number):Point | ||
{ | ||
// projection of v1 on v2 | ||
var proj1:Point = projectVector(ball, dx, dy); | ||
// projection of v1 on v2 normal | ||
var proj2:Point = projectVector(ball, lx, ly); | ||
|
||
// reverse projection on v2 normal | ||
var lang:Number = Math.sqrt(proj2.x*proj2.x+proj2.y*proj2.y); | ||
proj2.x = lx*lang; | ||
proj2.y = ly*lang; | ||
|
||
// add the projections | ||
var proj:Point = new Point(); | ||
proj.x = proj1.x+proj2.x; | ||
proj.y = proj1.y+proj2.y; | ||
return proj; | ||
} | ||
|
||
public static function projectVector(v1:Point, dx:Number, dy:Number):Point | ||
{ | ||
var dotProduct:Number = v1.x * dx + v1.y * dy; | ||
var proj:Point = new Point(); | ||
proj.x = dotProduct * dx; | ||
proj.y = dotProduct * dy; | ||
return proj; | ||
} | ||
} | ||
} |