Say for example I have an area that is 9x9.
I want to be able to use this area to report the position of a mob relative to the worlds maximum proportions
Example:
world.maxx = 100
world.maxy = 100
players position = 20,46
I wish to convert that into a manor that would display the players approximate position in a 9x9 representation of the world. It doesn't have to have anything to do with pixels, just flat coords is good.
Hopefully that makes sense to you.
Any help would be incredibly appreciated.
Thanks In Advance
- GunRunner
ID:168862
Aug 20 2005, 12:26 am (Edited on Aug 20 2005, 4:35 am)
|
|
Aug 20 2005, 11:40 pm
|
|
Use simple percentages. What percentage of 100x100 is does that player have? x percentage is 20%, y is 46%. 20% of 9 is 9/5 (1.8), so the x co-ordinate can be 2 in this special map. Get the idea?
|
In response to Jp
|
|
Jp wrote:
What percentage of 100x100 is does that player have? [blah blah] Get the idea? is does? When you're talkin jibberish, I can't get much of any idea. Hiead |
In response to Hiead
|
|
'Tis not gibberish. Maybe just impenetrable.
As far as I get it, GunRunner wants to put player icons or whatever on a 9x9 map, based on where they are in a 100x100 map. So find out the percentage of mob.x to map.x, as well as mob.y to map.y, and use that percentage for our location in the 9x9 map. |
In response to Jp
|
|
Jp wrote:
As far as I get it, GunRunner wants to put player icons or whatever on a 9x9 map, based on where they are in a 100x100 map. So find out the percentage of mob.x to map.x, as well as mob.y to map.y, and use that percentage for our location in the 9x9 map. Much better, thanks :) Hiead |
In response to Hiead
|
|
Hey man thanks heaps for that. I'm not gonna pretend I would've ever gotten it! I'll let you all know how it goes.
- GunRunner |
In response to Jp
|
|
Jp wrote:
Use simple percentages. What percentage of 100x100 is does that player have? x percentage is 20%, y is 46%. 20% of 9 is 9/5 (1.8), so the x co-ordinate can be 2 in this special map. Get the idea? Note that with the above calculations, the resulting coordinate is 0-based, not 1-based like the real map. Lummox JR |
In response to Lummox JR
|
|
Just make the map 10% the width of your map, and save yourself rounding everything off all the time.
|
In response to GunRunner
|
|
var/X = (world.maxx) Here's the code I have come up with... I'm sure this doesnt work properly as when you are at the locaiton of 100,100 it returns that the location would be at 11,11 on the map and that is outside the 9x9 area... Have I done something wrong or is it just not possible? - GunRunner |
In response to Nukes4U
|
|
Not really he point, I want it so that it'll adapt to any situation.
- GunRunner |
In response to GunRunner
|
|
GunRunner wrote:
> var/X = (world.maxx) Here's the code I have come up with... I'm sure this doesnt work properly as when you are at the locaiton of 100,100 it returns that the location would be at 11,11 on the map and that is outside the 9x9 area... Have I done something wrong or is it just not possible? Yep, you've done something wrong. There are two main things here that are incorrect. First, you took the word "percentage" too literally. You don't need to multiply by 100 here. Just having the fraction is good enough. Second, you divided by 9 instead of multiplying. That's probably a natural consequence of the first mistake, since you rightly figured that multiplying 100 by 9 scales it up by 900. Lummox JR |
In response to Lummox JR
|
|
Thansk heaps for the help, this is why we ask questions to learn!
- GunRunner |