Understanding the tile co-ordinates

All things HTML5 or text based engines, or really any web based engines.
Post Reply
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Understanding the tile co-ordinates

Post by robaldred »

I'm having some trouble understanding the tile co-ordinates. Specifically the overTiles() method, it seems to return points that are confusing me.
I want to be able to find out where my entities are and how many tiles away they are from other entities.

1st test:
Dog at x:0,y:0 overTiles() reports x:0,y:0, happy days.
Distance returns 0.
Screen Shot 2013-09-12 at 11.21.51.png
2nd test:
I've moved the dog to tile x:2,y:0, however overTiles() reports it's on x:1,y:-1 :?
Distance returns 1.4142135623730951
Screen Shot 2013-09-12 at 11.21.17.png
3rd test:
I've moved the dog to tile x:0,y:2, however overTiles() reports it's on x:2,y:2 :?
Distance returns 2.8284271247461903
Screen Shot 2013-09-12 at 11.21.31.png
4th test:
I've moved the dog to tile x:9,y:9 however overTiles() reports it's on x:14,y:5
Distance returns 14.866068747318506
Image
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: Understanding the tile co-ordinates

Post by coolbloke1324 »

Hey answering from my phone so will be short at moment but points are 2d unless told otherwise. Check iso example quests in character container class to see how to get iso coordinates from 2d point. It is very easy has built in method in igepoint.

Rob
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Re: Understanding the tile co-ordinates

Post by robaldred »

Ahh magic!

Code: Select all

entity._parent.pointToTile(entity._translate.toIso())
Thanks, I thought I was going crazy :)
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Re: Understanding the tile co-ordinates

Post by robaldred »

Hi again, so the tile positions are good!
However the distance method that's added to Math seems to get less accurate the further the distance.

eg.
Sheep is on 0,0

.1
I've moved the dog so it's on tile x:5 y:5
with diagonal pathing, the dog is 5 tiles away from the sheep.
However, distance calculation says 7

Code: Select all

Math.distance(0,0,5,5) # => 7.0710678118654755
.2
Moving dog to 9,9 distance returns 12

Code: Select all

Math.distance(0,0,9,9) # => 12.727922061357855
It's good enough for what I need, I need to check for entities on neighbouring tiles.
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: Understanding the tile co-ordinates

Post by coolbloke1324 »

Distance is calculated via pythagorean theorem and your results are correct. Remember the values are 2d coordinates not projected to isometric. The distance still works though. It is the hypotenuse line from point to point.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Re: Understanding the tile co-ordinates

Post by robaldred »

Do you know what maths would be to reliably calculate the distance in tiles between two iso tile points?
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: Understanding the tile co-ordinates

Post by coolbloke1324 »

robaldred wrote:Do you know what maths would be to reliably calculate the distance in tiles between two iso tile points?
X distance = startx - endx
Y distance = starty - endy

Now you know how many tiles in each vector the start position is away from the end position.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
robaldred
Posts: 64
Joined: Tue Aug 27, 2013 5:54 pm

Re: Understanding the tile co-ordinates

Post by robaldred »

Thanks for your help Rob
zaquanishak
Posts: 53
Joined: Mon Aug 26, 2013 1:54 am

Re: Understanding the tile co-ordinates

Post by zaquanishak »

Hi,
im having the same problem about the overTiles() method. Currently im using the overTiles method in my characterContainer class update method to compare which tile the character is step on. The code as below.

Code: Select all

 var tiles = this.overTiles(), playerReachDoor = false;

                if((tiles[0].x === 1) && (tiles[0].y === 1)){
                playerReachDoor = true;
                if(playerReachDoor === true){
                    ige.network.send('goToDoor' , {id: this.id() , map:2});
                    playerReachDoor = false;
                }

                this.break;
            }
but the location of the tiles is not the same similar problem as robaldred. So i would like to as how to i use

Code: Select all

entity._parent.pointToTile(entity._translate.toIso())
to convert the overTiles method to be isometric?

Please advise.

Regards,
Zachz
zachz
Programmer
compass-interactive
User avatar
coolbloke1324
Posts: 181
Joined: Mon Jan 23, 2012 5:20 pm

Re: Understanding the tile co-ordinates

Post by coolbloke1324 »

Hey ya,

I believe this has now been answered in a different question thread you made.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
Post Reply

Return to “HTML5/Web Engines”