Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: Vincent 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
-
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.
-
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 :).
-
Thanks guys!
I'll give it a try! ;D
-
Hey, there should be built-in functions to select from the dropdown for registering and removing callbacks for the main loop events.
-
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.
-
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.
-
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.
-
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! :)
-
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! :)
-
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.