Strategies in Game Design - murrieta.k12.ca.us
Game Maker : 1945
It introduces variables, properties, and ‘blocks’ of Actions
In a scrolling shooter the player controls an Object, for example a plane,
I. Key concept: “variables”
A. Definition: a variable is a value that can be changed or adjusted, Thus, when you define something in the game by setting a value for it (such as a number; and ‘true’ or ‘false’) you have “set a variable.” - better have a clear idea of what a ‘variable’ is and these concepts behind how they function in a game!
1. Local (or “Instance”) Variables apply to a specific instance of an Object, such as whether it is solid, or altering its position or speed. Each instance of an Object can have many variables and actions that change them.
2. Global Variables apply to variables not related to a specific instance of an Object, but to the overall game itself, such as keeping track of the score.
B. All variables must have a unique name.
1. Can only consist of letters and underscore symbols ( _ ).
2. Variable names are case sensitive,
3. Here are some sample Instance Variables / properties:
• x = the x-coordinate of the instance (i.e., where it exists horizontally on the screen by pixel number; pixels are counted from left side starting at number ‘0’)
• y = the y-coordinate of the instance (i.e., where it exists vertically on the screen by pixel number; pixels are counted from the top starting at number ‘0’ – the coordinate 0, 0 would be the top, left-hand corner of the Room)
• hspeed = the horizontal speed (in pixels per step; remember a ‘step’ = 1/30 of a second)
• vspeed = the vertical speed (in pixels per step)
• direction = the current direction of motion in degrees (0 to 360; 0 is not ‘straight up’ – the ‘0’ direction coordinate in Game Maker is horizontally to the right, what you might think of as 90 degrees)
• speed = the current speed in this direction (in pixels per step)
• visible = whether the Object is visible or invisible (see the sidebar to the left)
• solid = whether the Object is solid or not solid (see the sidebar to the left)
4. Here are some sample Global Variables built into Game Maker (there are many more):
• score = the current value of the score
• lives = the current number of lives the player has remaining
• mouse_x = the x-position of the mouse (horizontal)
• mouse_y = the y-position of the mouse (vertical)
• Room_speed = current speed of the Room (in steps per second); you’ll see this in action as the Room ‘moves’ in this tutorial lesson
• Room_caption = caption shown in the window title bar
• room_width = width of the Room in pixels
• Room_height = height of the Room in pixels
C. You can define your own variables and use them as well. It does help to label with the action if you want
Using Variables:
An Example
Let’s say we’re making a game where a spaceship flies around and shoots stuff. But we don’t want people to just hold down the fire button and receive a steady stream of laser bolts; we want our spaceship to be able to shoot only once every half-second (15 steps) in the game. That means we need to set up a variable for our spaceship indicating whether it can shoot.
We create a new variable for our game that we’ll call can_shoot to define this property of an Object.
In the Creation Event of the spaceship (i.e., when the spaceship is ‘born’ to our game world) we set this variable to ‘1’ (meaning ‘yes’ or ‘true;’ in other words, the spaceship is created ready to fire its laser bolts).
When the player wants to fire a shot, we have to check the value of this variable to see whether that action is allowed. Whenever a shot is fired, we set this ‘property’ (variable value) to ‘0’ (indicating that the variable is set to ‘no’ or ‘false’ and that firing a shot is not currently allowed).
We must also include an Alarm Event therefore to set this property back to ‘1’ after 15 steps have elapsed.
In a similar way, we could use variables to indicate whether the spaceship has an active shield, whether it has some special weapon upgrades, and so forth.
D. Important Control Panel buttons for variables
By selecting the control tab in the Object Properties screen, we find the three icons relating to variables. Let’s examine the first two, as we’ll be using them in this tutorial lesson.
[pic]
1. Set the value of a variable. Simply specify the name of the variable and the new value.
When you check the Relative box, the given value is added to the current value of the variable.
Note that you can only make the change to a variable Relative if it has something to be relative to. That is, the variable must already exist and have a value assigned to it!
The variable, you can also give a mathematical formula. These means you will define that variable with small mathematical statement instead of a simple number.
For example, to double the score when this variable occurs, you could set its value to 2*game_score.
2. If a variable has a value: Programmers call this an “if statement
If the value of the variable is equal to the number given, the question returns ‘true,’ and the next action (or block of actions) is then performed.
If it is not equal, the question returns ‘false,’ and the next action (or block of actions) is not performed.
II. Game Design for 1945: Fill in the information
1. Introduction: 1945 is a classic-style arcade shooter where the player controls a WW2 vintage U.S. Lockheed P-38 ‘Lightning’ fighter that flies upward across a Pacific Ocean screen that is scrolling to simulate movement. There are four different types of enemy planes arriving in ever-increasing numbers. The player’s goal is to shoot them (for points) and avoid colliding with them (to stay alive).
2. Game Components:
2.1 Terrain:
2.2 Units:
1:
2:
3:
4:
2.3 Effects: NEW
2.4 Audio:
2.5 User controls:
2.6 Information display: NEW
3. Setup:
4. Sequence of Events:
5. Rule: New
6. Levels:
7. Ending the Game:
8. Victory Conditions:
II. Creating the illusion of motion
A. The name ‘scrolling’ shooter tells you how the illusion of movement is created: the game world scrolls across the screen, either from top-to-bottom or left-to-right.
In 1945 the ‘world’ scrolls vertically from top-to-bottom. Even if the player’s airplane stands still on the screen, the scrolling background gives the illusion ‘flying’ over it.
When the player moves their plane, it gives the illusion of accelerating (as it moves forward) or decelerating (as it moves backward). Note that it is important that the plane does not move faster backwards than the background scrolls, or it will appear that the plane is actually flying backwards!
B. Creating a scrolling background in Game Maker
1. There are two ways to make a scrolling background with this software. The first (and easiest) way is the one we’ll use. It involves creating a tiled background image that simply moves downward through the Room (remember, in Game Maker “Room” = “level”). The other was is only a bit more complicated, and that is to build a much larger Room, but only showing part of it at a time using a “view” that slowly moves upward over the Room.
2. Let’s do it. Fire up Game Maker. Because this game takes place over the Pacific Ocean, we need a background image that looks like the sea viewed from above.
a) From the command menu, select Add, then Add Background. Name it back_water. Press the Load Background and look in the “Images” folder for a useable piece of art called ‘water.’ Press OK to save it and close this window.
b) Now let’s make the Room. From the command menu, select Add, then Add Room. Click on the backgrounds tab and uncheck the “Draw background color” box. (As we did with Catch the Clown, we’ve got a tile of art for the background now.) In that same frame, where it says , click on the blue ‘search’ button next to it and plus in your back_water background Sprite. All the grid squares should be nice and ocean blue now because the default setting is tile the whole Room with this art (and that’s exactly the look you want).
To make the background move, at the bottom of this window, set the Vert speed to ‘2.’ This form should now look like this:
[pic]
Click the OK button to save your Room. It will appear under the “Rooms” folder in the left frame. You may want to right click on the name “Room0” and change it to something like rm_main. Title 1945 Fighting Lightning
3. If we had graphic card Test it out. Run the game to verify that you have indeed created a scrolling background that gives the illusion of motion. From the command line, select Run, then Run normally.
4. add a few islands to the ocean to provide some visual ‘landmarks’ to fly over. The easy way to do this is to create a larger background image (Room size) and just plunk down a bunch of islands on it. The down side to that approach is that the islands will repeat in a regular pattern that player’s soon notice.
This is the same technique used in cartoons where you will notice a repeating scrolling background behind a running character.
We are making them objects
a) Create three Sprites, one for each island type as shown on the left. (You’ll do the Add, Add Sprite thing three times.) You’ll find the art files for “Island1” “2” and “3” there waiting for you.
You don’t want Objects in this game (e.g., airplanes and their bullets) to collide with the islands, so uncheck the Precise collision checking box. Give them snappy file names like spr_island1 and save them.
b) After creating the three island Sprites, you have to create three island Objects using those Sprites. From the command line, use Add, Add Object.
Make a Create Event for each island (using Add Event below the Events box). The first Action for that Create Event is to Start moving in a direction so that it is scrolling at the same speed as the Room background (that is, setting it to ‘2’), thus keeping the island in the same relative position in respect to the scrolling sea. You can do that by selecting the move tab and finding the red ‘down arrow’ icon. Drag it over to the Actions box and set
the speed to ‘2.’
Now it’s time to learn about depth. Instances of Objects are drawn in layers on top of (‘over’) each other in the order of their Depth setting from highest (drawn first) to lowest (drawn last). That is, instances with the higher numbers are drawn first and instances with a lower number are drawn on top of them. So, on the left panel in the Object Properties window, chance the default value of the Depth setting (‘0’) to 10000. By giving the islands a high Depth setting they will always be drawn first and stay below the instances of other Objects in the game.
There’s one more thing to be done for each island. When it scrolls off the bottom of the screen and disappears, we want it to pop up at the top again. To do this, create a regular Step: Step Event (using Add Event below the Events box, select Step and Step Event). Now, we’re going to use a variable to test whether the island disappeared below the screen and, if it has, to make it reappear at the top.
To create the Action for this Step Event, select the tab on the right labeled control and drag the blue octagon VAR (“If a variable has a value”) icon over to the Actions box. In the pop-up definition window, set the variable (where the blinking cursor is) to ‘y’. Note that the variable y simply indicates the vertical position of the instance (and a value of ‘0’ corresponds to the top of the Room).
The value to check for is called Room_height which indicates the value of the height of the Room (in pixels). Type in ‘room_height’ on the next entry line, value. You want the island to disappear when its y position is larger than the Room height (i.e., when it has scrolled off the bottom of the screen), so change the last line, operation, to read ‘larger than.’ You will then have a form that looks like the one above.
Click OK.
Now the Variable Action is set to check (‘test’) every step to see of that island has scrolled off the bottom of the screen. If that statement is true, then the next Action is performed, which is... what?
We want the island to reappear somewhere randomly along the top edge of the Room. To teleport it back to the top of the Room, you use the Action Jump to a given position.
The pop-up window, naturally, wants us to tell it where that position is using x and y coordinates. But you want that island to jump to a random position above the Room, not a particular pixel (this will prevent a ‘pattern’ developing that players will notice as they fly over the islands). So, how do we assign a random value to a coordinate?
Game Maker comes with a programming function called random(). There are many functions in Game Maker, but for the moment we only need the function random(). In the jump action for the x coordinate, type in ‘random(room_width)’; now the island will appear randomly along the top of the screen because the program will create a random value between 0 and the width of the Room for the ‘x’ coordinate.
For the ‘y’ coordinate, set the value to ‘–65’ (negative 65). Now the jump action form should look like the one above.
We use –65 for the y-position to make sure the island starts completely above the Room. Since each island Sprite is 64 x 64 pixels, we’ll start it at –65. Due to the Object’s innate vertical speed that you assigned it, it will soon move back into sight again.
Repeat these steps for the other two three islands Objects. See the sidebar I Copy That.
All that remains to be done is to initially place the three different islands at varying vertical heights within the Room. Double-click on your Room_name listed under ‘Rooms’ in the left frame. Select the Objects tab and plunk down one copy of each of your three islands.
Be sure to put them on different vertical rows!
Even though the islands reappear at regular moments, because their horizontal position is bring randomized, players should not notice that they are the same.
Want to see your islands in action? From the command line, select Run, Run normally. Pretty cool, huh? Save as lastname_1945_1
-----------------------
Solid? Visible? It’s all a bunch of ones and zeroes
These types of yes / no variables are defined by ‘setting a bit’ (a binomial value of either ‘0’ or ‘1’).
If the case is ‘yes’ or ‘true,’ the bit value is set to ‘1’ (i.e., ‘yes, it’s true).
So if the Object is visible, this variable’s bit would be set to ‘1.’
Conversely, if it is not visible, the bit value is set to ‘0’ (meaning ‘no, that’s false’).
This convention is so common among programmers that you can even type in the keyword “true” for the value of ‘1’ and “false” for the value of ‘0.’
These are the variable icons.
We’re interested in the square gray
Icon and the blue octagon.
Programmer Stuff
don’t leave spaces in a formula, and an asterisk ( * ) is used for the ‘times’ symbol instead of an ‘x.’
Thus, 2*game_score for the variable value means the new value will equal the current game score value times 2.
Island 1
Island 2
Island 3
What is a
‘Step’ Event?
A Step Event means something that is checked every step (1/30 of a second) of the game.
Here you can assign actions that need to be executed continuously. That is, they are checked every turn as part of the game’s Sequence of Play.
For example, if one Object should follow another, here you can adapt its direction of motion towards the Object it is following.
What is a ‘Function?’
A function computes a value (or performs an action) based upon the value of certain arguments. The argument(s) are written between the brackets after the function name.
Anyplace where you can type in values in Game Maker, you can also use functions and variables (and expressions describing these variables).
I Copy That
One cool shortcut that you can use to make the other two island Objects is to right-click on the obj_island1 item in the left frame under ‘Objects’ and select Duplicate from the pop-up window. Then just go in and edit it by putting in the next island’s correct Sprite and name.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- marketing strategies in business
- promotional strategies in marketing
- mde k12 ms us child nutrition
- gisd k12 nm us home
- consumer relations strategies in healthcare
- questioning strategies in the classroom
- product strategies in marketing
- effective communication strategies in healthcare
- communication strategies in the workplace
- bcps k12 md us email
- product mix strategies in marketing
- evidence based strategies in education