repositioning for minimap location
Ive got a minimap that i draw on, the image is 300x300 in size and i'm displaying the player and enemies that are within range (500) of the player.
they have map coords that can be anything from (-1000, -1000) to (1000, 1000), i want to set the player to the center (150, 150) and then reposition enemies in my List (has a Point) within the minimap. What I'm having some problems wrapping my head around how to do display enemies. The "factor" is 6,666 (1000/150), can i just divide enemy开发者_开发知识库 position by this factor?
Should it be relative to players position? Lets say its (-1500, 39) and a enemy is at (-1000, 39), on his left hand side, how do i transform this to minimap where range for X and Y is 0-300?
The point should be positionned relative to your player, that will be at the center of your minimap. thus, on your minimap, each ennemy will be at a position (with a factor of 6.6666)
x = (xennemy-xplayer)/factor +150
y = (yennemy-yplayer)/factor +150
Please note that if you only display ennemies that are within range 500, then they will have a position (x and y) between 75/225, ie not the whole possible minimap. This is because the factor is based on the whole position range (to be at 0, you have to be at a distance of 1000)
Guillaume
精彩评论