• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
reppinfreedom

Angle and speed on an isometric map.

7 posts in this topic

Can someone verify that this math is correct? If your traveling up or down on an isometric map the speed of the character should be half that of traveling horizontal. What I am not sure about is traveling at an angle. The character speed should be the horizontal and vertical speeds divided together correct? So 0.75. This will be multiplied times the actual character speed.

Hmmm... Going to go see if I can find some information on eight directional isometric character movement speeds...

[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.75;
} else if (Angle == 90) {
angleSpeed.Animation="u";
angleSpeed.Speed=0.5;
} else if (Angle == 153) {
angleSpeed.Animation="ur";
angleSpeed.Speed=0.75;
} else if (Angle == 180) {
angleSpeed.Animation="r";
angleSpeed.Speed=1;
} else if (Angle == 206) {
angleSpeed.Animation="dr";
angleSpeed.Speed=0.75;
} else if (Angle == 270) {
angleSpeed.Animation="d";
angleSpeed.Speed=0.5;
} else if (Angle == 333) {
angleSpeed.Animation="dl";
angleSpeed.Speed=0.75;
} else {
angleSpeed=null;
}
return angleSpeed;
}
[/source] Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites
Here is something you should copy from the 3d world: world space and view space.
You should do all your game logic in world space, which should not differ between moving up or left. The view space is what you currently see and you need two functions to convert between the two spaces.
world2View(x,y) := (x-y*0.5,x+y*0.5) + (screenoffset_x,screenoffset_y)
view2World(x,y) := ...homework...

The world2View transformation is only needed for rendering your scene, please remember, that your world is somewhat turned by 45 degree, therefore you just can't make 1:1 conversion. The other way around (view2World) is needed whenever you want to convert input (e.g. mouse input) back to your world space.

There's some math involved which isn't hard, but makes the handling much easier. Once you work in world space independently of the screen lot of issues just vanish, like your movement example :D Edited by Ashaman73
1

Share this post


Link to post
Share on other sites
No, that math of mine was definitely not correct... I just checked the math...

Here are the tile distances...
Horizontal:92
Vertical: 46
Angular: 51.5 Rounded, Actually: (51.42956348249516)

According to my calculations angular speed should be... 0.55978260% of Horizontal. So a multiplier of 0.56 would be correct? Hmmm... That doesn't sound right... I think I need to calculate out non isometric tile distances first to solve this easier... Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites
I have conversion classes for converting between isometric and normal coordinates... I just want to keep the code lighter and faster.

If I wanted perfect accuracy I would calculate out everything on a non isometric coordinate grid. I would just set a velocity and angle... But, I want things to run faster and not require many conversions and calculations.
[source lang="java"]
public static function getXyVelocity(Velocity:Number, Angle:Number):Point {
var newPoint = new Point();
newPoint.x = - Velocity * Math.cos(Angle * Math.PI / 180);
newPoint.y = - Velocity * Math.sin(Angle * Math.PI / 180);
return newPoint;
}
[/source]

Then I would run a conversion to isometric velocity and angle from normal.

[source lang="java"]
package Michael{

public class iso3dTransformer {

static var Ratio:Number=2;
public static function convertToIso(screenPoint:Object):Object {

var zPos:Number=screenPoint.z;
var yPos:Number=screenPoint.y-screenPoint.x/Ratio+screenPoint.z;
var xPos:Number=screenPoint.x/Ratio+screenPoint.y+screenPoint.z;
return new Object(x:xPos,y:yPos,z:zPos);
}

public static function transformForDisplay(displayPoint:Object):Object {

var zPos:Number=displayPoint.z;
var yPos:Number=(displayPoint.x+displayPoint.y)/Ratio-displayPoint.z;
var xPos:Number=displayPoint.x-displayPoint.y;

return new Object(x:xPos,y:yPos,z:zPos);
}

}
}
[/source] Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites
When you already got your conversion code, just enter the unit vectors for your 8 directions [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img] , the unit vector for diagonal world movement (=horizontal/vertical screen movement) would be
x ~= 0.707, y ~= 0.707 (change sign accordingly).
0

Share this post


Link to post
Share on other sites
The problem is I only have one of the cartesian to polar/polar to cartesian functions I need both functions to solve this...

I need to convert the x/y velocity from the normal to isometric conversion function into speed and angle... Hmmm... *Searching.* Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites
Okay... So I created a function to convert a x/y velocity into an angle...

Now, I need to solve for the velocity... It something as simple as Math.sqrt(xVel + yVel)?<br />
[source lang=&amp;amp;quot;java&amp;amp;quot;]<br />
public static function xyVelToAngle(xyVel:Point):Number {<br />
   var Angle:Number = Math.atan2(xyVel.y,xyVel.x);<br />
   var Degrees:Number = 360 * (Angle / (2 * Math.PI));<br />
   if (Degrees &amp;amp;lt; 0) {<br />
    Degrees = Degrees + 360;<br />
   }<br />
   return Degrees;<br />
  }<br />
[/source] Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites
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 Edited by reppinfreedom
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0