[Game Programming Galaxy]
[Logo]
[Design]
Date: Mon, 20 May 1996 08:08:16 -0500 (CDT)
From: Lennart Steinke
To: Jason Kaczor
Subject: Re: Help: Isometric/Axonometric
[...]
How to get mouse coordinates... that's another problem.
At least it was for me. It took me some time, messing
around with some "cunning ideas"... finally, I've been
using two linear equations.
Treat the rotated x-y axes as lines, and check where they
connect with the screen axes.
I'm using world coordinates (imagine the complete map
drawn in a BIG offscreen buffer. Every point has now its
unique coordinates... that's what I call world coordinates),
and calculate the coressponding map coordinates only when
neccessary (scrolling, collision detection).
Say, your (ground) tiles are 32x16. I call the half width
q and the half height p. That gives us the slope m with
p/q = 0.5
for the isometric y axis, (-m) for the x axis.
W0x, where the line hits the x axis is
W0x=(map height)*q
so, for our [3/3] map, W0x equals 48
W0y, where the lines x coordinate is zero is
W0y=0-m*W0x
so, W0y is -24.
A line is defined as
y=mx+b ->
b=y-mx ->
x=(y-b)/m
Say, in a 3/3 map with 32x16 tiles, and a given point P(x=48/y=8),
which is in the center of map(0/0).
xm + y
( ------- - W0x ) / (2q) = x'
m
48*0.5 + 8 32
( ---------- - 48) / (32) = (----- - 48) / 32 = (64-48)/32 = 0.5
0.5 0.5
Now, the y coordinate
| (y- mx) - W0y | | 8 - 0.5*48 - (-24) | | - 16 + 24 | | 8 |
y'= ----------------- = ---------------------- = ------------- = -----
2p 16 16 16
8
y'= -- = 0.5
16
Hope that helped.
Feel free to ask further questions.
Lenny
--
Lennart Steinke (lennart_steinke@bigfoot.com)
[Image] [Image] [Image]
------------------------------------------------------------------------
| What's New? |
| Design | Tutorials | Projects | Tools | Genres | Tile based |
| Link Page |
------------------------------------------------------------------------
Designed and maintained by Lennart Steinke
lennart_steinke@bigfoot.com
Hosted by GeoCities
[Welcome to GeoCities!]