Trying to make a mini map. (Solved)

Started by Overlord, Fri 02/05/2008 17:34:41

Previous topic - Next topic

Overlord

For the game I'm working on I have a large room set up like an ocean, and basically the player is a boat. The problem is it's easy to get lost.

I want to make a mini map, so I plan to use a GUI in the top right to show it, but I have no idea how I could show the players position on the map. Any suggestions on how I could do this?

DoorKnobHandle

The problem you're having at the moment doesn't seem too be coding- but rather design-related. You can only begin worrying about how to implement (program) something if you know exactly how you want it to work, if it is designed. What I do in these cases is sit down with Paint or equivalent opened up and just sketch out ideas of how I want it to work. Also, try thinking about how other games present this feature.

Once you have that down, come back, tell us what you have in mind, then maybe try doing it yourself first and you will get all the help you need here.

Welcome! :)

Overlord

Thanks for the reply.

Well so far my I've got a gui with a smaller version of the map. And a character that is the like "You are here" dot. If I can figure out how to find the players position, my idea is to divide that how small the Minimap is compared to the large(Say 4 times smaller), and have the dot character take the players position divided by 4. I think it'd work?

Khris

Sure. Say it's a scrolling room at 1280x800, and your minimap is 160x100.
Divide the player's coordinates by 8, then load the small map graphic into a DynamicSprite and draw the dot on top, then set the sprite as the GUI's background image.

Overlord

#4
Edit: Ok, I've got it to work except one thing. When the dot is going across the map, it leaves copies of itself behind, basically creating lines across the map. The code I'm using is

Edit: Made it a room script
// room script file
function room_AfterFadeIn()
{
gMap.Visible = true;
gStatusline.Visible = false;
MapGui = DynamicSprite.CreateFromExistingSprite(167);
MapGui.Resize(60, 60);
gMap.BackgroundGraphic = MapGui.Graphic;
}

function room_RepExec()

{
MapDot = DynamicSprite.CreateFromExistingSprite(168);
DrawingSurface *surface = MapGui.GetDrawingSurface();
surface.DrawImage(player.x/7, player.y/7, MapDot.Graphic);
MapDot.Delete();
}

Khris

Try "surface.Release();" before MapDot.Delete();

Overlord

#6
That didn't work. Thanks though.



Shows the problem.

JpSoft

I solved this  in our RTS game as follow:

Main background is 1280 x 800
gMinimap is 160 x 100, and its backgroundimage is the same as the main BG (resized with a single image editor)
bPosition (in gMinimap) is 2 x 2 and you can update its position with Game.GetViewPort.

For example, if cEgo is actually at position 200,200 in the screen,

WhereX = cEgo.X;
WhereY = cEgo.Y;
WhereX = WhereX + GetViewPortX();
WhereY = WhereY + GetViewPortY();
WhereX = WhereX / 8;
WhereY = WhereY / 8;
bPosition.SetPosition (WhereX, WhereY);

You can update 30 different things (limit controls per GUI) by this way.

You can also set gMinimap.Transparency = 50 if you want a more professional result and even set to change the ViewPort according to a click over the GUI.

Hope this helps.

Jp

Overlord

#8
That might help, I'm just having trouble on where that code would go. That transparency really makes the map look better though. Thanks:)

Edit: Oh wait, got it to work! Thank you so much!

Thanks to everyone else who helped too:D

SMF spam blocked by CleanTalk