Home > SoulHow > SoulHow to work with views (Game Maker)

SoulHow to work with views (Game Maker)

June 24, 2008

NOTE: Comments are locked. I no longer answer questions about the Game Maker tutorials on this blog; I suggest you take any questions to the Game Maker Community. For more info, view the FAQ page.

Skill Level: Novice user (4)

Well hello again. You’re reading another SoulHow article, this time about Game Maker’s views. I’m going to cover all of the settings in the views tab of the room editor in GM version 7.0; all those things that had cool names but you didn’t dare touch.

First off; what is a view? A view is Game Maker’s way of looking at only one part of the game at a time. Many commercial games use a system of views; in fact, nearly all of them now days do. Super Mario Bros. even used them; imagine what the game would be like if you could see the whole level at once! Very small (due to having to get the whole level to fit in size of the television), and boring as well.

That’s where views come in. They tell Game Maker, “this is how I want the player to be able to see the game.” You can make them as big or small as you want, and some settings are better for certain games. Due to that fact, I’m going to walk you through each setting and let you decide which one is right for your game; experiment with it!

Head over to the room editor of Game Maker (open Game Maker and make a room if you haven’t already for some reason…) and click the “views” tab. You should be here:

The first thing you see is a checkbox marked, “Enable the use of views”. This is like the master throwswitch for all views. If you’re going to use views at all, it has to be checked, so check it now.

Underneath that, we have a selection box with “view 0, view 1, view 2, view 3,” etc. What is all this? Well let me tell you…in song! *reggae*

Seriously folks. The reason there are all these numbers of views is because you are allowed to have up to 8 views at any time. Usually you only use one, or at the most, two (or sometimes four, for multiplayer games like car racing). Most people just stick to using view 0, being that it’s the first view listed, but you can pick your favorite number I guess.

Okay, stick with view 0 for now, and let’s move on. Next we see another checkbox which says, “visible when room starts”. This checkbox is not related to every view but only one; you can have this checked for view 0 and unchecked for view 1. Maybe you want view 0 centered on where the player is in the level and view 1 to show the girl all tied up at the railroad tracks…or something. Whichever view (or views…but normally only one at a time) this is checked in, will be drawn (shown) on the screen.

Just to prove that it can be checked in one view and unchecked in another, check this box and click on to another view in the select list. The checkbox instantly unchecks. Now click back to view 0; the check is there again, almost as if by MORE WIZARDRY.

And moving on some more, we now see a “view in room” group box, with four textboxes: “X”, “Y”, “W”, and “H”. This looks difficult, what with all the lack of actual words, but it really isn’t. X is the horizontal position of the view in the room, that means, where the view begins. The higher the number, the more right-ward the view moves. Similarly, Y is the vertical position of the view. However, the higher the number, the more downward the view moves.

W and H stand for “width” and “height” respectively. In general you want to make the width and height have a 4:3 relationship; that is, the height should be equal to three quarters of the width. As you can see, the default values, 640 and 480, follow this convention. (640/4*3=480) Just the same, you could use “480” for width and “360” for height. The reason you should do this is due to the way the game is sometimes stretched to fit the screen (e.g. in fullscreen mode). If you don’t keep this 4:3 ratio, going to fullscreen might create an ugly black border along two sides of the game, because most monitors also have this ratio. So when making the view width and height, always take the width, divide it by 4, then multiply the answer by three, and if it equals your height, you’re fine.

Moving downwards some more, we see another similar group this time titled “Port on screen”, which requires some explanation. Just because it looks like the last thing we went over doesn’t mean it works the same way. “Port on screen” refers to where the view is drawn in the game’s window (the place where you play the game). Usually X and Y here remain at 0 and W and H match W and H in the “view in room” setting. The only time really that they’d be different is if you wanted to stretch or shrink the game’s graphics, but it doesn’t generally produce pretty results.

Sometimes you want more than one view to be seen at once, for example in two-player car racing games. In these situations, you could set view 0’s port to X=0, Y=0, W=320, H=480, and view 1’s port to X=320, Y=0, W=320, H=480; check both views’ “visible when room starts” boxes; and have a splitscreen game.

The reason is because we used the port settings. We told GM to put view 0 on the screen starting at the left side (X coordinate = 0) and have a width of half our window’s width (that’s why we used 320; this is assuming that you want a window which is the default 640 pixels wide). Therefore, it will take up the left half of our screen. View 1’s settings tell it to start at X=320 (where view 0 ends) and go another 320 pixels for a total of 640 pixels (our desired window width). Note the vertical stuff, Y and H, simply make each view begin at the top (Y=0) and end at the bottom of the view (after 480 pixels).

Also note that to decide the window size, GM finds the largest port coordinates and uses those. For example, with width, it goes through all the active views (those with “Visible when room starts” checked), and adds the Port’s X number to its W number. The largest result it finds is the window’s width. So in the above case, GM would go to view 0, see that it’s “visible when room starts”, and add X to W (0+320). Getting 320, it remembers that, and moves on. In view 1, it finds “visible when room starts” checked yet again, and adds X and W here as well. This time acquiring the number 640, it realizes that this is the last active view and that 640>320. Thus 640 is used for the window width. The same thing is done for the window height but with Y and H.

Great, now we got all that stuff out of the way, we’ll move on to the last group box: “Object following”. This part is used to make the view follow along with the player as he moves through the level. The drop down box there that says, “no object”, is used to tell GM which object the view should follow. Hbor and Vbor are the horizontal and vertical borders, respectively. These “borders” are how close the specified object must be to the edge of the view for it to move. So when that object passes those borders, the view shifts into position instantly so the player is never offscreen (unless he moves outside the whole room).

Hsp and Vsp are two more things that need some explanation. They’re shortened versions of “hspeed” and “vspeed”, which stand for the view’s horizontal and vertical speed. See, normally, when you put -1 in these boxes, the view instantly pops into a correct position, never allowing the player, or whatever object you want to follow, to be offscreen.

However, putting a different number here allows the player to go offscreen, if only for a small time. The reason is that the speed you place is how fast the view moves (kind of a duh thing, if you think about it). If the player moves off the screen at a speed of 8 and you give the view a speed of 4, the player moves twice as fast as the view scrolls, and it won’t keep up. Eventually, the player will be off the side of the view until he stops and the view has time to reach him. This seems like a lame feature, but it has its uses; imagine what Sonic the Hedgehog would have been like if you couldn’t run off the edge of the screen after bolting down the side of a mountain. For games which don’t center around speed, however, stick with -1 (instant scrolling).

I guess that’s everything. Experiment with all these settings (there’s no harm) and see what you like.

If you enjoyed this article, please consider checking out the rest of the blog.

If you have a technical question, such as “How do I do this” or “this is not working right” (relative to something with your Game Maker game after reading this tutorial), please head over to the Game Maker Community and ask there.  I can’t answer any such questions in this blog and the members at the GMC will be more than capable to help you.  For more info, go to the FAQ page on this blog.

  1. August 2, 2008 at 6:13 pm

    Thanks for the post

  1. March 29, 2013 at 2:43 am
Comments are closed.
%d bloggers like this: