Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Calculating In-Game map positions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 PoliticalChaos   Members   -  Reputation: 151

Like
0Likes
Like

Posted 04 December 2012 - 10:38 AM

Hello everyone,

I have an issue. I'm not going to send what I have because it's extremely hard to understand and most likely horribly written because of my lack of knowledge on this subject. So lets just start from a simple approach, if I want to take a game object and put its position on a world map or mini map how would I take that 3D position and convert it to a 2D position that can be used to position the map marker?

Thanks to anyone who can help me!

Sponsor:

#2 DgekGD   Members   -  Reputation: 374

Like
2Likes
Like

Posted 04 December 2012 - 10:45 AM

One of the approaches is to make two more render passes for your scene. The first new one would render to texture everything from the camera which is located in the sky. In the second new render pass you render this texture to the place on the screen you want.

#3 PoliticalChaos   Members   -  Reputation: 151

Like
0Likes
Like

Posted 04 December 2012 - 10:52 AM

Thanks DgekGD, I'll try that out. It actually sounds like a really good way of doing it. If anyone else has any suggestions on this, please let me know.

#4 bauer   Members   -  Reputation: 288

Like
1Likes
Like

Posted 05 December 2012 - 06:21 AM

If you already have a top-down overview image of your map, you could just convert your object's position into "minimap coords".

To convert between real coordinates and minimap coordinates:
normalized_coordinate = object_position / map_bounds
minimap_coordinate = normalized_coordinate * minimap_bounds

For example:
Real map is 100 units X and 100 units Y
Minimap is 256 pixels wide and 256 pixels high
Object is positioned at 50,50 (center of map)

50 / 100 = 0.5 so the normalized object position would be 0.5, 0.5
0.5 * 256 = 128 so the unit should be positioned at pixel 128,128 in the minimap

Hope that makes sense, this was written while eating a donut :)

Cheers
----------------------------
BauAir Studios - Music & Sfx
www.bauair.se




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS