# Get absolute from relative?

### » Fri Oct 15, 2010 10:40 pm

Ok math question again.
Im working with a distort map's get sprite vertexX, and vertexY (Sprite.VertexXY(Column, Row)), but that only returns a relative value from the sprites (I'm guessing) size, IE distort sprite absolute at column 0, row 0 to sprite x +0= 0, and distort sprite absolute at column 0, row 0 to sprite x +sprite width= 1, width x 2 would be 2 etc.
So my question is, is there any way to get the real world or absolute x from that?
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

### » Fri Oct 15, 2010 11:25 pm

yes theres a way, but you need to find out if its the offset from a specific points original position or from the sprites center

if its an offset from that specific points original location your going to need to figure that out then add the xy offsets.

so lets say you distort object is a 64x64 square, with a distort map of 2,1 (3x2)

first your going to need to know which X(column),Y(row) your using, then your going to need to find out the top left corner's xy location(of the square, non distorted of course). its important that you keep track of the distort map column/row size and keep it in 0 based form, and keep its angle and width/height at the original objects values or else it might not work unless you implement something to get around that in the upcoming formula.

so now that you have those things, you need to actually put all that info into a formula that'll do what you intend.

so

for X:
sprite.left+((sprite.width/sprite('distortmapColumns'))*{current column})+Sprite.VertexX({current column},{current row})

for y:
sprite.top+((sprite.height/sprite('distortmapRows'))*{current Row})+Sprite.VertexY({current column},{current row})

and im pretty sure that'll work.
if im completely out of the ball park its because the assumptions i made were wrong (i dont have a comp to test if i understand the elements of the problem correctly)
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

### » Sat Oct 16, 2010 11:15 am

Alright will test that out, thanks.

I am curious as to why get vertexX is giving width tho...
I mean I was hoping it would at least give relative pixel coords.
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

### » Sat Oct 16, 2010 4:10 pm

Ehh I think for my purposes I may just go with a dummy to get the world x,y.
Your equation may work with some tinkering, but I think I would have to add a pv to keep track of a "virtual" column/ row for "sprite('distortmapColumns')".
Im guessing what I would need to do is split up the display (displaywidth/(spritewidth/map columns)), and keep track of where that would be in the pv.
The cap shows kinda what I was hoping vertexX did.

[url:2p4bu7h7]http://dl.dropbox.com/u/666516/getvertexabsolute.cap[/url:2p4bu7h7]
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755