Using Multiple Views

From GMWiki, the Gamemaker Wiki.

Jump to: navigation, search

Contents

[edit] Using Multiple Views

Many games use only one view to see the action in the game. However it can be quite fun, or even necessary to use more than one view in a game. Common uses for multiple views are:

  • Multplayer (i.e. Split Screen)
  • Minimaps
  • Zooming

[edit] Split Screen

In a multiplayer game, you may find that having two players play on one computer(hotseat) is the only viable way of including multiplayer. In this case, you will either need to have both players share one view, either by limiting movement or having the view accomodate for the player's movement, or you can have a seperate view for each player (and possibly even one as an entire level view).

To do this, you will need to have two, or more, views enabled. The views must be set up so that they take up the correct amount of space, i.e. if you'r total size is 800*600, and you want two equal views, aligned vertically, you will need to views that are 800*300 in size and port, with one view located at 0,0 and the other at 300,0.

When you have set up your views, you may find that you want to draw specific things in a specific view, for example, if your first player's view is view[0], and you want to draw only his lives in that view, before drawing the lives, you may do a simple check, in drag and drop;

Image:drawing_view_current.PNG

and in GML;

if (view_current==0){
      draw_text(view_xview[0],view_yview[0],self.lives);
      }

[edit] Minimaps

In some games, particularly Real Time Strategies, you may wish to have a certain part of the playing field visible to the player, but also have a smaller view indicating the entire playing field. To do this you would need a minimap.

Minimaps can be made in several ways, the easiest of these is to have a second view. Set the second view's size to the entire game room's size, but the port size to only a portion of the room's size. This way, the entire playing field will be visible, only very small, and a larger view can be seen of a smaller area. You can also use view checking so that HUD's aren't drawn in the minimap.

[edit] Zooming

There are many ways to do zooming in Game Maker. Zooming using two views can be good for things like sniping. To do this, it is almost a reverse of the aforementioned minimap process. The second view's size must be set to only a small portion of the view, while it's port should be set bigger. This stretches the small viewsize to the larger port size, giving the effect of zooming.

Personal tools