Game Development Reference
In-Depth Information
Mini-Map
Do you have a large room with a small view? Then you may want to give the player a bit of help in
navigating around by creating a mini-map somewhere on the screen. With the power of views,
we'll describe several variations on the theme using a small unfinished space shooter in which
you track down and obliterate asteroids.
Start with: Reference/Framework/spaceship4.gmk
Creating a Simple Mini-Map Showing the Entire Room
1.
Let's first check the current configuration. In room_test , select the settings tab. The
room's dimensions are currently at 1600x1200 pixels, so we'll use these values to create
the mini-map. Now, select the views tab. As you can see, there is only one view
configured. It's set at 640x480 and will follow obj_spaceship around. The borders are
half the view's size, which makes Game Maker center the view around the spaceship
anywhere unless it nears the borders of the room.
2.
Click on View 1 and check the Visible when room starts check box. Views are drawn on
top of each other, with view 0 being the bottom view, view 1 on top of that, view 2 on
top of that, and so forth. We could actually stack up to eight views if we wanted to!
3.
The View in room settings specify what part of the room will be visible in our mini-
map. Leave X and Y set to 0 , but change the width and height ( W and H ) to 1600 and
1200 , respectively.
4.
The Port on screen settings specify where on the screen our view will be drawn. You
would probably want to put this in an area that is not used by any of the other views,
but for the moment, we'll just place it in the top-left corner. For both X and Y , enter 20 .
The width and height ( W and H) allow us to change how much of the room is to be
resized. You should keep the proportions in line with the room, otherwise you'll
squeeze or stretch the projection. We'll just make the mini-map 10 times smaller than
the room itself, so specify 160 for the width and 120 for the height.
5.
The mini-map is ready, but if you would do a test-run at this point, you'd notice an
issue with it: it also draws the score. And it looks really strange, as the score is set to
follow the view around. To fix this, double-click obj_display , select the Draw event,
and double-click the Execute Code action. This action takes care of drawing the score
in the right place in the view, but it should not be drawn in the first view. Change it to
read the following:
 
 
Search WWH ::




Custom Search