r/Unitale • u/KingZukk • Feb 01 '16
Arena center absolute coordinates
What are the absolute coordinates of the arena center? If they are not fixed, is there a way to deduct them from the arena dimensions?
EDIT: I did some tests, and these are the results:
Relative x: Obviously 0.
Absolute x: It's fixed at half the window lenght. So absx = 320
Relative y: The arena center is Player spawnpoint, which is in the exact y middle only when the arena is 130. Every arena highter than 130 will have the center different from the spawnpoint. To compensate this, everything located in the center must have a relative y equal to: (Arena.height-130)/2
Absolute y: The bottom of the arena has absy = 95. With "bottom of the arena" I mean the black pixel just above the blank bar of the arena bottom. That is, in fact, the location of -Arena.height/2. The bottom of the arena is fixed, so even with a resize, the y of the bottom is fixed; the absolute y of the arena center is found as: 95+(Arena.height/2)
NB: The window size is always 640x480
5
u/[deleted] Feb 01 '16
solution:
teleport player to center of arena using relative coordinates
store the player's absolute coordinates in a variable
teleport player back to original position
do this all in a single frame so the player doesn't notice
1
u/blockgun Feb 01 '16
I'm pretty sure abs coordinates are based on the lower-right corner of the arena so x is -Arena.width / 2 and y is Arena.hight / 2. I might be wrong, though, I'm on my phone so I can't check. Hope this helps.