mini map math
Posted 10 February 2012 - 06:41 PM
Posted 10 February 2012 - 06:52 PM
Posted 10 February 2012 - 06:56 PM
Posted 10 February 2012 - 08:12 PM
I haven't done a ton of minimap stuff either, but I want to say that adding a new view and zooming it way the heck out for your minimap might be a little cpu intensive. It's my understanding that comps have a harder time shrinking sprites than they do enlarging them. I'm not an expert, though, and depending on the size of your game it could be negligible.
Posted 10 February 2012 - 09:16 PM
It has to do with math (like almost everything in game dev ). Now I regret I skipped math courses. Back to the topic:
There are numerous ways to do it. One would be this:
In the draw event of every mini-mappable object you draw 2 times.
Say you use 1024 x 1024 room, you got a 100 x 100 minimap in the top left of the screen and a car:
1024 / 100 = 10.24 is the divider;
draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, direction, c_white, 1); // what GM generally does draw_sprite(miniCar, image_index, x / 10.24, y / 10.24);so the math involved in here is dividing normal scaled coords by how many times the minimap is smaller and adding the offset of minimap relative to the screen.
Edited by mireazma, 10 February 2012 - 09:26 PM.
Posted 10 February 2012 - 11:53 PM
my room size is 6400 4800, and my mini map is 150 100
soo, 6400/150 is about 42, and 4800/100 is 48
i tried using it without the vIew_xview and view_yview and just using x and y but that didnt work either not sure what i did wrong?
Posted 11 February 2012 - 10:01 AM
draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, direction, c_white, 1); draw_sprite_ext(sprite_index, image_index, view_xview + x/42.6, view_yview + y/40, 1/10, 1/10, direction, c_blue, 1);view_xview and view_yview are always at 0, 0 coords relative to screen so you have to offset the coords of the mini object to these vars.
Edited by mireazma, 11 February 2012 - 10:48 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users