Download presentation
1
Shooters in GameMaker J Parker
2
Scrolling Shooter In a scrolling shooter the player controls an object, for example a plane, spaceship, or car, which moves over a scrolling background. Obstacles appear on the background that must be avoided and enemies appear that must be shot. Often bonus objects appear that can be picked up for addition benefits. Examples: Space invaders, Galaxian
3
1945 The player flies in a plane over a sea and enemy planes try to destroy the player.
4
Variable A new concept in GameMaker, a variable is a property of an object that can be changed. - The position of an object has an X and Y value The speed of an object has a horizontal and a vertical part The score is a variable The height and width of the room are variables Etc etc etc
5
Variable A variable can be used to save an important value for later use (EG position of an enemy) A variable can represent a property of an object that is important and needs to be used by the game. A variable can be modified by the game, thus modifying how the corresponding object looks and behaves (EG change object’s speed)
6
Variable Changing a variable’s value is done as follows: On the CONTROL tab find Testing a value uses the button.
7
Setting a variable
8
Testing a variable
9
1945 Design Description In this game you control a plane flying over a sea. You encounter an increasing number of enemy planes that try to destroy you. You should avoid these or shoot them. The goal is to stay alive as long as you can and to destroy as many enemy planes as you can. Game objects The background is formed by a scrolling sea with some islands. The player’s plane flies over this sea. You can shoot bullets that destroy enemy planes. There are four types of enemy planes: a plane that you encounter and should be destroyed, a plane that fires bullets downwards, a plane that fires bullets towards the player’s plane, and a fast enemy plane that comes from behind rather than from the front.
10
1945 Game objects The background is formed by a scrolling sea with some islands. The player’s plane flies over this sea. You can shoot bullets that destroy enemy planes. There are four types of enemy planes: a plane that you encounter and should be destroyed, a plane that fires bullets downwards, a plane that fires bullets towards the player’s plane, and a fast enemy plane that comes from behind rather than from the front.
11
1945 Sounds There are some explosion sounds and there is some background music. Controls The player controls the game with the arrow keys. With the space key you fire a bullet. Only one bullet can be fired every five steps.
12
1945 Game flow The player immediately jumps into the game. The player has three lives. When all lives are gone a high-score table is shown. Pressing the <F1> (help) key will give a brief explanation. Pressing the <Esc> key will end the game. Levels There is just one level, but more and more enemy planes will arrive: first only the easy type but later the more difficult types.
13
Motion – An Illusion There are two possibilities for creating the motion illusion: use a tiling background image that moves downwards through the room. build a much larger room but only show part of the room using a so-called view. This view slowly moves upwards over the room. We will use a moving background.
14
Water We need a background image that looks like a sea viewed from above. We add the following small image as a background resource to the game and give it the name back_water: Filling the background with it will give a nice looking sea.
15
Water In a scroller, the background image should move. To create a room with a moving background, add a room to the game in the familiar way. At the left click on the tab labeled backgrounds. We need to change three settings here. 1. First of all, because we are going to fill the whole room with the background image, so uncheck the box labeled Draw background color.
16
Water Second, in the middle click on the menu icon and select the back_water background image. The default setting is to tile the whole room with it so this is what we want. Finally, we need to make the background move. To this end, at the bottom, set the Vert. speed to 2. Now try it.
17
Motion, water, islands, ... To enhance the feeling of motion we are going to add a few islands to the sea. An easy way would be to create a larger background image and add the island to this background. Iislands will appear in a regular pattern, which the player soon notices. (Bug Bunny) So we choose a slightly more complicated approach and add the islands as objects.
18
Motion, water, islands, ... Create three sprites with the following images We will never use them for collision checking so uncheck the box Precise collision checking. For each of the islands we create an object. In the creation event we give the object a vertical speed that is the same as the scrolling speed of the background.
19
Motion, water, islands, ... To make sure that all other objects will stay above the islands we give the island objects a Depth of (You must run Game Maker in advanced mode to be able to do this!) Instances of objects are drawn in the order of the depth. The instances with highest depth are drawn first. Instances with lower depth are drawn on top of them. So by giving the islands a high depth they will always be drawn first and lie below the other objects.
20
Now – a trick! When the island disappears below the bottom of the room we want to make it reappear at the top. In the Step event of the island we test whether the island disappeared below the screen and, if so, let it reappear at the top. Note that the variable y indicates the vertical position of the instance.
21
a trick! A value of 0 corresponds to the top of the room. The variable room_height indicates the height of the room. So the island disappears below the bottom of the room when y is larger than room_height. We can use the action to test variable values to see whether the island lies below the room...
22
a trick! So: When the island moves off of the screen at the bottom, and can not be seen any longer, it causes a copy of itself to be made above the screen (where it can not be seen) and at a random horizontal position. It will then move down, onto the screen (becoming visible) and off again, repeating... Only one instance will be seen at a time. This is actually computer programming!
23
a trick! Motion Motion
24
a trick! You can use a variable name, and can actually type full expressions here.
25
So the process is: In Island object select a STEP event and choose the ‘If a variable has a value’ action. The room (what you can see) has a vertical size (in pixels) of room_height, and starts at a value of 0. This is the ‘y-axis’ as they told us in high school. The position of the island is the variable y. So if y > room_height then we want to move the island.
26
Where to move to? Negative values of y are above the screen (room). Move islands to y = -65 Moving to the same x position is dull. Select a random x within the room random (room_width) This is in a jump to a given position box in the same STEP event.
27
The player’s airplane Is controlled by keys. The sprite we’ll use is a small GIF animation. Makes it look like the propellers are moving. Can shoot – space key. Should look like the shooting comes from the centre of the plane. Sprite is 65 pixels, centre is 32,32
28
Player Motion events (initially) are the arrow keys. Plane must not leave the room, so check! <left> if X is larger than 40 Jump to given position -4, 0 relative to current.
29
Player Similar for the other 3 directions: <right> if X is smaller than room_width-40 Jump to 4, 0 relative to current. <up> if Y is larger than 40 Jump to 0, -3 relative to current. <down> if Y is smaller than room_height-120 Jump to 0, 3 relative to current.
30
The player’s cannon We need a bullet sprite. We put its origin in the centre as we did for the main plane. To make it a bit spectacular we use a rather large bullet. Exaggerating things is often important in games. Create an object with this sprite. Creation even: give it a vertical speed of –8 to make it move upwards. Destroy it once it leaves the room - in the step event we test whether the variable x is smaller than –16.
31
The player’s cannon In the plane’s object box, make an event for pressing the <space> key. This event creates a new bullet instance. An idea: only create one if there are no others. Use the TEST INSTANCE COUNT as we did with diamonds before.
32
The player’s cannon We don't want too many bullets too fast. How about two bullets every second? This is one bullet every 15 steps. Use a variable can_shoot This is created in a create event for the plane by using a set variable command box. We initially set can shoot to 1 (true)
33
CAN SHOOT Now in the event, keyboard, space key event:
Is CAN SHOOT equal to 1? If so, create a new bullet in front of the plane (0,1-6) set CAN SHOOT to 0. Set alarm0 to 15. alarm0 ???
34
Alarms An alarm is an ‘automatic’ event that happens when a specified number of game steps have taken place. It is like a timer. If we set alarm0 to 15, then it becomes 0 in 15 steps. At that time and alarm0 event happens, and we can use that to set the CAN SHOOT variable back to 1 again. Thus we can shoot every 15 steps.
35
Blocks We also need to group actions in the <space> event.
36
Enemy Planes Type 1: It is a small plane that simply flies downwards.
It does not shoot but when it hits the main plane the game is lost. Create sprite, read it in. Create object, assign sprite, vertical speed=4 When plane hits the botton it redraws at randome above the room. Needs: collision with bullet, with player.
37
Enemy 1 Collision with bullet: it explodes and vanishes Use ADD SOUND and load an explosion noise. These are WAV files, prerecorded. Need a sprite for the explosion, origin 16,16. It is a small animation. Once it finishes playing there is an event called ANIMATION END that we use to destroy the sprite (actually, we’ll MOVE it) Bullet action,collision with plane1: delete self
38
Enemy 1 Collision with player: it explodes and vanishes Use an explosion noise. Game is over: print message and stop.
39
High Score
40
The Game should get harder...
We start with one enely plane, and spawn more and more, and different kinds. How do we do that? Using a game agent. We create one more object: controller_enemy. It will control the creation of enemy planes. We make the object invisible during the game by unchecking the box labeled Visible. A sprite is not required for it.
41
The Game should get harder
In its creation event we create an enemy place at a random location just above the room. (the first enemy) We also set the alarm clock to 200. In the event for this alarm clock we create another enemy plane and set the alarm clock again, but this time to 500. The effect is that at the beginning of the game there is one enemy plane. After 200 steps, that is, about seven seconds, a second enemy plane appears. After about 15 seconds, a third plane appears, etc.
42
High Score
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.