• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #Actualreppinfreedom

Posted 18 November 2012 - 03:52 AM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees-180; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

Edit: Changed "velAngle.Angle = Degrees" to "velAngle.Angle = Degrees-180"... Now correct!

Those functions were a little funky... This should be more proper and readable.

[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = radToDeg(Angle); velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; } public static function angleBetweenPoints(Location:Point, Target:Point):Number { var dx:Number = Location.x - Target.x; var dy:Number = Location.y - Target.y; var Angle:Number = Math.atan2(dy,dx); var Degrees:Number = radToDeg(Angle); return Degrees; } public static function radToDeg(Radian:Number):Number { return Radian * 180 / Math.PI; } public static function degToRad(Degree:Number):Number { return Degree * Math.PI / 180; }[/source]

Ok, this is what I came up with...

[source lang="java"]public static function animationAndSpeedToNextRowCol(currentRowCol:Object, nextRowCol:Object, tileSizeX:int, tileSizeY:int):Object { var angleSpeed:Object = new Object(); var Angle:int=Math.floor(gameMath.angleBetweenPoints(rowColToPoint(currentRowCol,tileSizeX,tileSizeY),rowColToPoint(nextRowCol,tileSizeX,tileSizeY))); if (Angle == 0) { angleSpeed.Animation="l"; angleSpeed.Speed=1; } else if (Angle == 26) { angleSpeed.Animation="ul"; angleSpeed.Speed=0.707; } else if (Angle == 90) { angleSpeed.Animation="u"; angleSpeed.Speed=0.5; } else if (Angle == 153) { angleSpeed.Animation="ur"; angleSpeed.Speed=0.707; } else if (Angle == 180) { angleSpeed.Animation="r"; angleSpeed.Speed=1; } else if (Angle == -154) { angleSpeed.Animation="dr"; angleSpeed.Speed=0.707; } else if (Angle == -90) { angleSpeed.Animation="d"; angleSpeed.Speed=0.5; } else if (Angle == -27) { angleSpeed.Animation="dl"; angleSpeed.Speed=0.707; } else { angleSpeed=null; } return angleSpeed; }[/source]

Edit: Ok... I finally managed to run a test that generated the numbers for me... These are the final multipliers simplified to four decimals of accuracy.

Sideways: 1.4142
Angle: 1.118
Up/Down: 0.7071

### #5reppinfreedom

Posted 18 November 2012 - 03:34 AM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees-180; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

Edit: Changed "velAngle.Angle = Degrees" to "velAngle.Angle = Degrees-180"... Now correct!

Those functions were a little funky... This should be more proper and readable.

[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = radToDeg(Angle); velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; } public static function angleBetweenPoints(Location:Point, Target:Point):Number { var dx:Number = Location.x - Target.x; var dy:Number = Location.y - Target.y; var Angle:Number = Math.atan2(dy,dx); var Degrees:Number = radToDeg(Angle); return Degrees; } public static function radToDeg(Radian:Number):Number { return Radian * 180 / Math.PI; } public static function degToRad(Degree:Number):Number { return Degree * Math.PI / 180; }[/source]

Ok, this is what I came up with...

[source lang="java"]public static function animationAndSpeedToNextRowCol(currentRowCol:Object, nextRowCol:Object, tileSizeX:int, tileSizeY:int):Object { var angleSpeed:Object = new Object(); var Angle:int=Math.floor(gameMath.angleBetweenPoints(rowColToPoint(currentRowCol,tileSizeX,tileSizeY),rowColToPoint(nextRowCol,tileSizeX,tileSizeY))); if (Angle == 0) { angleSpeed.Animation="l"; angleSpeed.Speed=1; } else if (Angle == 26) { angleSpeed.Animation="ul"; angleSpeed.Speed=0.707; } else if (Angle == 90) { angleSpeed.Animation="u"; angleSpeed.Speed=0.5; } else if (Angle == 153) { angleSpeed.Animation="ur"; angleSpeed.Speed=0.707; } else if (Angle == 180) { angleSpeed.Animation="r"; angleSpeed.Speed=1; } else if (Angle == -154) { angleSpeed.Animation="dr"; angleSpeed.Speed=0.707; } else if (Angle == -90) { angleSpeed.Animation="d"; angleSpeed.Speed=0.5; } else if (Angle == -27) { angleSpeed.Animation="dl"; angleSpeed.Speed=0.707; } else { angleSpeed=null; } return angleSpeed; }[/source]

Auuugh...

I also came up with 0.625 and 0.80...

I have no idea which number is correct. Converting back and forth between ISO 3D and 3D is confusing the hell out of me. I am going to stick with 0.80. Honestly... Players wouldn't even notice if the number is off. LoL!

### #4reppinfreedom

Posted 18 November 2012 - 12:48 AM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees-180; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

Edit: Changed "velAngle.Angle = Degrees" to "velAngle.Angle = Degrees-180"... Now correct!

Those functions were a little funky... This should be more proper and readable.

[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = radToDeg(Angle); velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; } public static function angleBetweenPoints(Location:Point, Target:Point):Number { var dx:Number = Location.x - Target.x; var dy:Number = Location.y - Target.y; var Angle:Number = Math.atan2(dy,dx); var Degrees:Number = radToDeg(Angle); return Degrees; } public static function radToDeg(Radian:Number):Number { return Radian * 180 / Math.PI; } public static function degToRad(Degree:Number):Number { return Degree * Math.PI / 180; }[/source]

Ok, this is what I came up with...

[source lang="java"]public static function animationAndSpeedToNextRowCol(currentRowCol:Object, nextRowCol:Object, tileSizeX:int, tileSizeY:int):Object { var angleSpeed:Object = new Object(); var Angle:int=Math.floor(gameMath.angleBetweenPoints(rowColToPoint(currentRowCol,tileSizeX,tileSizeY),rowColToPoint(nextRowCol,tileSizeX,tileSizeY))); if (Angle == 0) { angleSpeed.Animation="l"; angleSpeed.Speed=1; } else if (Angle == 26) { angleSpeed.Animation="ul"; angleSpeed.Speed=0.707; } else if (Angle == 90) { angleSpeed.Animation="u"; angleSpeed.Speed=0.5; } else if (Angle == 153) { angleSpeed.Animation="ur"; angleSpeed.Speed=0.707; } else if (Angle == 180) { angleSpeed.Animation="r"; angleSpeed.Speed=1; } else if (Angle == -154) { angleSpeed.Animation="dr"; angleSpeed.Speed=0.707; } else if (Angle == -90) { angleSpeed.Animation="d"; angleSpeed.Speed=0.5; } else if (Angle == -27) { angleSpeed.Animation="dl"; angleSpeed.Speed=0.707; } else { angleSpeed=null; } return angleSpeed; }[/source]

### #3reppinfreedom

Posted 18 November 2012 - 12:18 AM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees-180; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

Edit: Changed "velAngle.Angle = Degrees" to "velAngle.Angle = Degrees-180"... Now correct!

Those functions were a little funky... This should be more proper and readable.

[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = radToDeg(Angle); velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; } public static function angleBetweenPoints(Location:Point, Target:Point):Number { var dx:Number = Location.x - Target.x; var dy:Number = Location.y - Target.y; var Angle:Number = Math.atan2(dy,dx); var Degrees:Number = radToDeg(Angle); return Degrees; } public static function radToDeg(Radian:Number):Number { return Radian * 180 / Math.PI; } public static function degToRad(Degree:Number):Number { return Degree * Math.PI / 180; }[/source]

### #2reppinfreedom

Posted 18 November 2012 - 12:00 AM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees-180; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

Edit: Changed "velAngle.Angle = Degrees" to "velAngle.Angle = Degrees-180"... Now correct!

### #1reppinfreedom

Posted 17 November 2012 - 11:50 PM

Aha... Viola! Now this should be correct in converting xyVel into a velocity and an angle... Now I should be able to solve it.
[source lang="java"] public static function xyVelToVelAngle(xyVel:Point):Object { var velAngle:Object = new Object(); var Angle:Number = Math.atan2(xyVel.y,xyVel.x); var Degrees:Number = 360 * (Angle / (2 * Math.PI)); if (Degrees < 0) { Degrees = Degrees + 360; } velAngle.Angle = Degrees; velAngle.Vel = Math.sqrt(xyVel.x * xyVel.x + xyVel.y * xyVel.y); return velAngle; }[/source]

PARTNERS