Game Development Reference
In-Depth Information
One of the things that seems to be missing from Game Maker when you first start to create
games is an event for when a specific key is not being pressed. You start something moving in a
Keyboard, Left event and you add a Keyboard, <No Key> event to stop it moving again.
Unfortunately the <No Key> event only gets called when no keys are being pressed on the
keyboard at all. So once you have started an object moving left, then you can keep it moving left
by holding any key down on the keyboard —even the right arrow key! Similarly, solutions using
Key Release events can also be tricky to make work in all situations.
So for Zool, we have created a solution to this kind of problem by taking advantage of the
event order. We set the state to ZSTATE_STAND in the Begin Step event, and create Keyboard, Left
and Keyboard, Right events that reset the state to ZSTATE_WALK . If neither key is being pressed,
then the state will still be ZSTATE_STAND in any of the Step , Collision , End Step , or Draw events as
they occur after the keyboard events. The left and right keys will set the state appropriately, but
any other key will have no effect on the outcome.
Note Actually, in the registered, Pro version of Game Maker 8, you can now add your own Trigger
events that can detect the user pressing (or not pressing) any combination of keys you like.
Room with a View
If you try running the game at the moment, then you will discover that your entire room is
displayed in one very large window. Fortunately, Game Maker provides views as a means of
changing how much of the room you can see at once, and even settings to make that view
automatically follow a particular object around the room. We know that the entire test room is
2048 pixels wide by 640 pixels high (see Figure 3-9), but how much of it do we want to see at
once? The screen resolution on the original (Amiga) version of Zool was only 320x256 pixels,
which didn't give a wide view of Zool's surroundings. We're going to be a bit more generous and
adapt our aspect ratio to fit a widescreen monitor by giving players a 512x300 pixel view window
into the room. However, modern monitor resolutions are much higher than this, so this would
create a pretty small window on your desktop. Therefore, we will also scale up the output of this
view by doubling it up to 1024x600 pixels—you can always hit F4 to go full-screen if you have a
really high desktop resolution and you want the full effect.
Setting Up the Room View
Open room_test from the Rooms resources folder and select the views tab. Check the
Enable the use of views option and select View 0 from the pane below it. The settings
below this pane now refer to View 0 .
1.
2.
Check the Visible when room starts option and set View in room to X = 0 , Y = 0 , W = 512 ,
H = 300 . You should see a rectangular outline appear in the room panel marking the
boundary of the view we will be copying. The X and Y positions of the view are actually
irrelevant, as we will make the view follow the position of the Zool object below.
Set Port on screen to X = 0 , Y = 0 , W = 1024 , H = 600 . So if you think of the previous step as a
copy operation, then this is the paste . It will paste the view to an X , Y position of (0,0) on
the player's window, but scale up the width and height to double its original size as
part of the pasting process.
3.
 
Search WWH ::




Custom Search