Author Topic: Metroid-like Minimap  (Read 4020 times)

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Metroid-like Minimap
« on: 2009-10-06, 01:05:46 PM »
Okay guys, this one is a real bugger!

My game is going along well, and as the first level of the game is near completion (for the layout) I'm thinking of a way to add a minimap to the game.  And, if not possible, a minimap into the menu.

To get you in context, the game is a metroidvania: a recent game that came out and uses exactly the kind of mini-map I want is "Shadow Complex" available in XBoxLive arcade.
Starting around the 45th second of the video, the gameplay begins.  You can see on the top-right corner of the screen a rectangle subdivided in squares.  This is the mini-map. 
http://www.youtube.com/watch?v=z7WI7XrLfKU
Notice, as the character moves around, that the minimap is revealed.  My game can easily be divided in such map squares.  It would definitely be a huge help in my game, since the levels can be confusing without a minimap.

I guess the first step would be to add an overlay map to manage the minimap, but I already have one specified that is used to show the stats of the player (current health, magic, current skill selected, current skill active.

So, I guess I would need 2 overlay maps at the same time.  Is that possible?

Also, what would be the best way to make a relation between the actual level and the minimap, the reveal the proper locations and scroll the minimap logically?

I guess, if it is too difficult, I will add a menu option to look at the complete map.  But I bet players would prefer to have the minmap rather than going in and out the menu to see where they are and where the are going every once in a while.

What do you guys think?

Thanks a lot! :D
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Metroid-like Minimap
« Reply #1 on: 2009-10-06, 08:03:24 PM »
You can have multiple layers in your overlay map if you want, and manage them as separate logical entities.

As for the minimap, I think it may be a bit difficult, but you could try linking the player sprite to a sprite in the minimap that scrolls to the current section the player sprite is in.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Metroid-like Minimap
« Reply #2 on: 2009-10-06, 09:36:51 PM »
To reveal the map as it is explored, my first idea is to make the mini map a new layer on the overlay map and copy tiles to it from the current player location on the main map as the player moves around, scrolling the mini-map relative to the player's location on the main map.  There are two problems/challenges I foresee with this approach:
1) You'll probably have to write code to scroll the mini map layer to a position that corresponds to the main map's player position.  But it should be relatively simple: just set the Layer's CurrentPosition property directly (this is what the map does to the layer when the map scrolls, but you need more direct access since the overlay map does not scroll).
2) The mini-map should not cover the entire overlay map.  Maybe you can derive a new class from ByteLayer like MessageLayer did in GeneralRules.cs.  Then you can control how the layer draws instead of allowing it to pick up the view from the map's CurrentView while drawing.  Of course you will not be able to add this layer to the map in the conventional way.  You'll probably have to maintain it somewhat separately, kind of like MessageLayer is handled.

The next idea that comes to mind is to have a totally separate map that you create manually and draw manually over (or under) the overlay map, which might be easier in the sense that SGDK2 can manage much of the scrolling and view size automatically if you set it up correctly, but then you have to figure out the best way to insert code to draw the map as part of the main loop.  One way to do this without modifying any standard code, I believe, is to use the OnBeforeDrawOverlay or OnAfterDrawOverlay event.  You can create some custom code object with a function you can call once to attaches a handler function to the OnBeforeDrawOverlay event.  Then it will get called every time right before the overlay map is drawn, giving you an opportunity to draw your own manually managed map between the main map and the overlay map.  Hey, I thought of everything :).

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Metroid-like Minimap
« Reply #3 on: 2009-10-07, 06:55:59 AM »
Thanks guys! 

I'll give it a try!  ;D
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Metroid-like Minimap
« Reply #4 on: 2009-10-07, 07:49:15 AM »
Hey, there should be built-in functions to select from the dropdown for registering and removing callbacks for the main loop events.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Metroid-like Minimap
« Reply #5 on: 2009-10-07, 03:19:51 PM »
Generally, since you have to write the code that's going to handle the event anyway, I expect that whoever writes the handler code will include a function to access it (link it to the appropriate event) in the same code object.  Then "regular users" don't have to be confused by unusable functions, and won't risk hooking up events to handlers that don't make sense.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Metroid-like Minimap
« Reply #6 on: 2009-10-08, 07:50:55 AM »
Well, maybe there could be a set of functions to go with it that would be useful to link in.  No idea what, but just to have some examples would be enough to justify including it in the list.
Edward Dassmesser

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Metroid-like Minimap
« Reply #7 on: 2009-10-08, 08:39:40 PM »
I suppose the mini map functionality is as good an example as any.  The messages were originally using these events, but it turned out they were more cleanly implemented without them.  Maybe the mini-map will work out better.

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Metroid-like Minimap
« Reply #8 on: 2009-11-07, 08:59:49 PM »
Hi guys!

To develop the minimap, I removed my "status" overlay (the one showing health, magic left, etc).  So I develop the minimap in a separate overlay.  I pretty happy with the results: it's almost a perfect replica of the one used in Shadow Complex!  :) 

I posted an screenshot, you can see the minimap in the upper-left corner.  The parts that are greyed out are rooms that haven't been visited.  The red "O" means that there is an objective to complete.  I also used green "S" for save points, blue "T" for teleport rooms and red dots for items to be found.  When objectives are completed or items taken, the symbol disappear from the minimap.  I think it's pretty straight forward and easy to understand.

I have found the OnBeforeDrawOverlay event, so I'm about to use it.  I'll keep you informed of my progress. :)
Thanks again guys! :)
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

Vincent

  • SGDK2 Addict
  • Expert
  • Fanatic
  • *****
  • Posts: 612
  • Legacy of Kain: Revival is completed!!!
    • View Profile
    • Chivalrous Games
    • Email
Re: Metroid-like Minimap
« Reply #9 on: 2009-11-07, 09:55:19 PM »
Wow!  The minimap coexists with the status overlay: this is GREAT STUFF!!!  ;D

It was really easy to do too!

I updated the project in the repository to show it off!  8)
Can you accept the update bluemonkmn?

Thanks a lot again!  :)
Legacy of Kain: Revival completed!
http://lokrevival.webs.com

See also my company website:
http://chivalrousgames.com

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Metroid-like Minimap
« Reply #10 on: 2009-11-08, 05:56:06 AM »
That sounds like great news (that it was easy)!  Upload approved.  I'm working this weekend, but I get next Thursday and Friday off in exchange, so I hope to get time to look at it then if not before.