Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Dec 2001
Offline Last Active Sep 04 2016 04:02 AM

#5084373 Trouble understanding Enet tutorial

Posted by on 09 August 2013 - 06:17 AM

Hm I'm afraid I can't answer most of your questions right now, they are probably more suited for the ENet developers. I haven't used ENet much in the last year and I've never checked through the source. I need to dig up some source code from old projects to get a better grip on how I used to do things. :)

#5007371 Calculating In-Game map positions

Posted by on 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 :)