How to make a Minimap
Author: | Sumo148
|
Submitted: | 25th May, 2009
|
Views: | 5598
| Rated: |
|
|
For a long time, I've wanted to add a minimap to my game and I have finally made one. I haven't seen any tutorials on how to make minimaps, and I know there's an extension coming out, but the source was lost (from phiziks). I'm going to show you how to make your own, since building one from scratch is always better
What You'll Need:
You'll only need a few objects in order to make the level editor work. Here's a list of them:
A Player (active)
A Enemy (active)
Minimap background (active)
Dot representing player (active)
Dot representing enemy (active)
Well you look at that! Only five actives! Okay read on to learn how to code it.
How To Set Up:
You can make your minimap any size, but I recommend using the dimensions 100x100. Place your minimap background in the top left corner of the screen. Move the dots out of the playing area. Also leave the bad guy and the player on the field. For this tutorial to see the results, put your player's movement to eight directions. For the dots, you want them to be small shapes with different colors to represent them easily. (For example, use red for the enemies and green for the player). Oh and be sure to uncheck "follow the frame" for everything but the player and enemy so it will scroll with you!
How To Code:
In order for this to work, you need ratios. The minimap background is essentially the playing field, but shrunk. So when the player moves, you need the dot that represents the player to move on the minimap as well but correctly using the ratio. To set this up, use an ALWAYS command under the dot representing the player, then enter this:
X( Player )/RATIO+X( Minimap Background )
Y( Player )/RATIO+Y( Minimap Background )
To get your RATIO, you have to divide your frame's width by your minimap's background width. Same goes with the height, but divide your frame's height by your minimap's background height. For example, if you were using the frame dimensions of 640x600 and minimap background of 100x100, it would look like this:
X( Player )/6.4+X( Minimap Background )
Y( Player )/6+Y( Minimap Background )
Finally, enter this code for the enemy's dot, but change the X and Y Player to Enemy. Your done! Now run the frame and when you'll move around you'll see that your dot also moves around correctly! Hopes this helps!
|
|
|