If I wanted to have an active object snap to an ISO-grid without using the isogrid object, what coding would I use? I'm sorta lost.
Yhanks,
--Jayklik
If I wanted to have an active object snap to an ISO-grid without using the isogrid object, what coding would I use? I'm sorta lost.
Yhanks,
--Jayklik
I would go for an 3 dimensional array, and let some math take care of positioning.
Another great solution, in case the object actually don't move in height, is to program everything in plain 2D, and hide that outside the window area, and then show an isometric representation of that.
Some formulas for you:
Definitions:
TopPointX / TopPointY = the x / y coordinate of the topmost point of your grid (the 0,0 tile)
isoWidth / isoHeight = the width / height of your isometric grid pieces
To convert isometric coords to screen coords:
isoX / isoY = the x / y coord of the tile to find
screenX = TopPointX + (isoX - isoY) * isoWidth / 2
screenY = TopPointY + (isoX + isoY) * isoHeight / 2
To convert screen coords to isometric coords:
screenX / screenY = the x / y coord of the point on the screen
isoX = Floor( (screenX - TopPointX + 0.0) / isoWidth + (screenY - TopPointY + 0.0) / isoHeight )
isoY = Floor( (screenY - TopPointY + 0.0) / isoHeight - (screenX - TopPointX + 0.0) / isoWidth )
Note I haven't tested these but they should be correct :P
Edit:
to make the object snap to the grid, convert it's position to isoX/isoY coordinates (stored in counters / alterable values) then convert it back again. The Floor part of the second formulas will make it snap to the grid
I'm sorry. I don't fully understand what is being said. Mainly, I don't understand the toppoint variables. Would they be 0,0 on the playfield? I appologise, but if you have some spare time, could I have an example? \
Thanks,
--Jayklik
Example file:
http://www.dje.me.uk/Examples/IsoPositions.mfa










In isogrid 2 u use the SnaptoY, SnaptoX and SnaptoLvl commands to do prettymuch the same thing. Follow tigerwork's example (the editor because the movement one is bugged atm) that's how i learnt to use it.
Both methods are prettymuch the same. except one uses an extension and the other math.
Thanks, Guys. I appreciate all of the help! And brovil, Thanks for the example! Thanks everyone.
--Jayklik
Oh... Umm, I'm having another problem. My cursor only moves on the Y axis, no matter where I move my mouse. Is there a problem with my events: Screenshot? Thanks for the help.










its because u've used an Always and the Y axis is loaded last - it looks like it cancels out the X axis code because u've overwritten the Alterable Values before it gets to use them. You're better off using Iso Grid, its soo much simpler.
ok, where you've got +0 that should be +0.0 It's only added to force MMF to use decimal values (it auto-rounds otherwise) It probably isn't needed at all, but I'm not sure (I seem to remember that there's a problem with negative coordinates without it)
The problem you're talking about is because of the second action (Set Alterable Value B) which has "... + (XMouse..." instead of "... - (XMouse..." (half way along) Just change the + to - and it'll be fixed.