Question
Use Gamemaker Studio. Give me a zip file. Create sprites for the player plane and for the background Right click on Sprite and select Create
Use Gamemaker Studio. Give me a zip file.
Create sprites for the player plane and for the background
Right click on Sprite and select Create sprite in the resourcepanel.
rename the sprite spr_plane
In the Sprite window hit Import and select the“myplane_strip3.png”
image.
Similarly, create another sprite in the same way, rename itspr_water,
import the water.png image.
3. Go to the room editor and select the Background layer. Selectspr_water for our background. Also, check mark the boxes forHorizontal and Vertical Tile. Set the vertical speed to 4.
4. Right click a. b. c.
on Objects and create a new object.
Name this object obj_plane. Set the spr_plane sprite toobj_plane.
In the events panel, add a new event: Key Down - Left
search for the Jump To function in the search bar and drag it intothe
window.
Type -2 in the x field. This will make the plane move to the lefton the X axis. Check mark both of the Relative boxes. Relativitymeans: At our current position.
Repeat this process for Key Down - Up, Right, Down. Hint: RightisPositive on the X axis. Up is Negative on the Y axis. Down isPositiveon the Y axis. *In Game Maker, the Y axis gets smaller thehigher you go
d.
e.
and gets bigger the lower you go. as shown in the image below.*
5. Now, lets add some music.
a. Right click on sounds and create a new sound. Name thissnd_music.
Select the Ride of the Valkyries soundtrack.
b. Create a new object named obj_music. This object does notneed a sprite. c. Add a Create event to this object and drag a PlayAudio function in.
d. Select our snd_music file and check mark Loop.
6. Finally, drag and drop both obj_player and obj_music into theroom. Hit play!
Part 1: Setup
Logon to Canvas
Navigate to the Week 4 page
Download and import the activity files:
a. For GM Studio 2.1, pick Partial Game - GameMaker Project
Start GameMaker
For GM Studio 2.1, unzip file and open project
In GameMaker open Scrolling_Shooter_PARTIAL > MyGame.ypp >MyGame
Make sure the project runs
Part 2: Player Object Movement Boundary Issues
Note that holding the down arrow slows down the plane and thatholding the up arrow makes the plane go faster.
Edit the object named obj_plane to do the following:
Allow the plane to be moved all the way to the bottom of theroom.
Allow the plane to move 100% faster than it currently does whenthe up arrow is
pressed.
Hint: Change the value of the test variables (If expressions) inthe and
events.
Note that the plane is able to fly backward, which does not makemuch sense for an
airplane. You can test this by reducing the vertical speed ofthe background.
Modify the action in the event to ensure that the plane movesusing a
value based on the speed of the background, instead of ahard-coded value.
Hint: Use the speed of the background. In GM 2.1 you need to getthe vertical
speed of the background layer by accessing it’s id.
Test your changes by making the background moveslower/faster.
Part 3: Adding Enemies, Bullets, Scores, etc.
Create a single enemy object
Define an object named obj_enemy1
Set the sprite to spr_enemy1
Use the Create event to set the enemy’s vertical speed to 4
Use the Outside Room event to add a Jump To Point action thatplaces the
enemy at the top of the room at a random value in thex-axis.
Add a couple of instances of the object to the room.
Run the game
Make the Enemy Dangerous
Use a Collision event to make the player’s plane explode when itis hit by an
enemy plane. Do this in obj_enemy.
i. Add an action to play the snd_explosion2 sound
ii. Change the sprite of the enemy object (self) tospr_explosion2iii. Destroy the current instance of the player’sobject (other)
iv. Run the game
Notice that the explosion keeps playing in a continuous loop andthat it continues to move and reappear. To fix this:
Modify the collision event to set an Alarm after destroying theplayer’s instance.
15 steps should be enough
Use Alarm 0
When the alarm goes off, destroy the enemy object’s instance(self).
Hint: Setting an alarm tells an Alarm event when to go off. Oncethe alarm goes off, the actions inside of the alarm event willtrigger.
Use a Controller Object to Create Several Enemies
Create a new object named obj_enemy_controller
i. The object does not need a sprite ii. The object is notvisible
Create event makes 1st enemy instance and sets Alarm 0 to 200.i. Make sure to set appropriate x and y values
Alarm 0 creates more instances and resets Alarm 0
i. You may want to wait a little longer to create the secondinstance
Edit the room
Remove the enemies that you previously added
Add a single instance of the obj_enemy_controller object
Run the game.
4. Firing at The Enemies
a. Create a sprite for the bullet
i. Name it spr_bullet
ii. Use the image bullet.png from the Scrolling_Shooter_Resourcesfolder
(same one from last class).
iii. Edit the sprite to ensure that the pointy end faces up on thescreen.
Note: There is a more robust solution, which you will implementin a few
steps.
1. Use the Rotate function in the Image menuiv. Center it
b. Create
i. Name it obj_bullet
an object for the bullet
Use spr_bullet
On Create set its vertical speed. It needs to move up.
On Outside Room –> Destroy the Instance
c. Modify the player’s object to fire bullets
Add a Keyboard Event for
The action creates an instance of obj_bullet
Check the Relative box. Consider why this is necessary.
d. Test the game
i. Test what happens if you keep the spacebar pressed
e. Add more actions to the keyboard event to limit the rate offire.
It needs to look as follows:
Make sure that you have an event for Alarm 0 that sets can_shootto 1
NOTES:
can_shoot is initialized on the object’s Create event
You may adjust the rate of fire by changing the number ofsteps
used by the alarm
The bullet is harmless, we will fix that next.
5. Destroying Enemies with Bullets
First, we have to create a new object that is used when an enemyplane
explodes:
i. Name the new object obj_explosion1
ii. Set the sprite to spr_explosion1
iii. On Create (event), play the sound snd_explosion1
iv. On Animation End (event), destroy the object’s instance
Add a Collision event to obj_enemy1. The event takes place whenthe enemy plane collides with a bullet fired by the player(obj_bullet).
c. The event should have the following actions:
In action #1, destroy the instance of obj_bullet not theplane
In action #2, check the Relative checkbox to create the instancewhere the plane
was.
In action #3, we move the enemy plane to a location outside ofthe room. This
enables us to reuse the plane. Use the Jump To Point action.
i. X is set to: random_range(0, room_width - 32)
g. Note that action #4 is used to add five (5) points to thescore. We will display score and other game information next.
6. Drawing the Scoreboard and Keeping Score
It is a good practice to dedicate one object to manage gameelements such as the player’s health, total lives. This object canalso be used to display the scoreboard or HUD, if your game hasone. Create a new object namedobj_life_controller for this purpose.This object does not have a sprite.
Add a Create event with the following actions:
Do not set relative on any of these. We will use the alarmlater.
c. Set Health with respect to obj_plane, set lives and scorewith respect to obj_life_controller. This will allows us to destroyour obj_plane instance and retain our lives and score.
d. Add a Draw event with the following actions, making sure theyapply toobj_plane:
Configure the actions as shown below:
NOTE: Make sure that all of these actions are set to apply toobj_plane.
Note that
. Please note that using the code in other actions or in scriptrequires the use of temporary variables. For example, to
correctly display the Health Bar for obj_plane, you would need asequence of actions similar to the one shown in the followingimage.
Add an instance of obj_life_controller to the room.
Run and test the game.
Make sure to destroy some enemy planes.
Make sure to get hit by an enemy plane. Do you notice aproblem?
7. Implementing Multiple Lives and a Health System
The player’s plane explodes after hitting an enemy just a singletime. Let’s fix that.
Note the obj_explosion1 that you created in part 5.
i. Make sure to examine the object’s Create and Animation Endevents.
c. Note that an object named obj_explosion2 has already beencreated.
Follow the image below and make note of the If Instance Existsand the
Create Instance actions.
Make sure to set health to obj_plane and set lives toobj_life_controller.
GameMaker (2.1) no longer supports the No More Lives and No
More Health events. Instead, GameMaker now provides Drag andDrop
(DnD) Actions to set, get and check the value of built-in Livesand Health
variables that are kept per instance
iii. iv.
d. Modify the event that handles the Collision event betweenobj_enemy1 andobj_plane as follows:
i. In action #1, set:
Applies to: Self
change into: obj_explosion1 perform events: yes
ii.
In GameMaker Studio 2.1, you need to use the DnD actions
. Using these you can check the value of the plane's healthwhenever a collision occurs and at
that point decide whether to destroy it. The game DnD actionsshould be similar to what is in the following image.
specifically designed to handle Health and Lives
e. Run the game. Make sure that the player’s plane collides witha few enemy planes and watch the health bar when this happens.
8. Creating Enemies that Fire Back!
Create a new object named obj_enemy_bullet1 i. Set the sprite tospr_enemy_bullet1
ii. On Create set the vertical speed to make the object movedownward iii. On Collision with the player’s plane do thefollowing:
Change instance of bullet to obj_explosion2
Play the sound snd_explosion1
Reduce the player’s health by 5
Check if health of the obj_life_controller is <= 0, if sodestroy the
plane instance
iv. On Outside Room destroy the instance of the bullet
Create a new object named obj_enemy2
Set the sprite to spr_enemy2
Set the Parent property to obj_enemy1
Add a Step event with the following actions:
On Action #2, make sure to check Relative
Modify the obj_enemy_controller object as follows:
On Create set Alarm 1 to 400
Add an Alarm 1 event with the following actions:
Note that this uses the inheritance feature of GameMaker, whichis very
useful when we have objects with similar functionality but thatrequire
some customization.
Create an instance of obj_enemy2. Make sure to place the newenemy in an appropriate location. It should not just appear in themiddle of the ocean.
Set Alarm 1 to 500
g. Run the game
9. Creating Bullets that Aim at a Specific Target
Duplicate the object named obj_enemy_bullet
Name the new object obj_enemy_bullet2
Set the sprite to spr_enemy_bullet2
Modify the Create event as follows:
on Action #1, check to see if obj_plane exists
Duplicate the object named obj_enemy2
Name the new object obj_enemy3
Set the sprite to obj_enemy3
Change the actions of the Step event as follows:
. See the following image for an example.
Modify the obj_enemy_controller object as follows:
On Create set Alarm 2 to 600
Add an Alarm 2 event with the following actions:
Note that on GM Studio 2.1, you need to first generate a randomnumber
(Integer) using the DnD Random action, which stores the resultin a temporary
variable. You can then check the result and use it to decidewhether to create a
bullet
Create an instance of obj_enemy3. Make sure to place the newenemy in an appropriate location. It should not just appear in themiddle of the ocean.
Set Alarm 2 to 600
j. Run the game
10. PowerupsandExtraLives
Create a new object named obj_extra_life
Set the sprite to spr_life
Add the following events and actions. Note that in GM Studio2.1, the No More
Lives and No More Health events are no longer available.Instead, you will need to check the value of Health for obj_planeand Lives for obj_life_controllerwhen the collision occurs andimplement logic to destroy the plane instance as needed. See thenotes above on the use of the DnD functions, such as Get Health andIf Health.
HINT: You may copy-paste actions from other Alarm events
and modify them.
Make sure that the object is created outside of the room (toppart) and that it moves downward, at a reasonable speed.
Modify the obj_life_controller object to set the Lives andHealth for the player’s plane, as follows:
11. Submission
a. Export your project
OR
Create a Zip archive
Step by Step Solution
3.45 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Part 1 Setup Log in to Canvas and navigate to the Week 4 page Download and import the provided activity files for GameMaker Studio 21 Unzip the downlo...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started