Tags:

Transcription

Game Maker: Maze TutorialTABLE OF CONTENTSWHAT IS GAME MAKER? . 2GAME MAKER SCREEN . 2LESSON 1 – THE CLOWN GAME . 4SPRITES - CLOWN . 4BACKGROUND – CLOWN . 6SOUND – BOUNCE . 6OBJECTS – WALL & CLOWN . 6CREATE EVENT – THE CLOWN . 7ALARM EVENT – THE CLOWN . 9COLLISION EVENT – THE CLOWN HITS A WALL . 9MOUSE EVENT – HIT THE CLOWN . 10ROOMS – ENTER THE CLOWN. 11LESSON 2 – THE MAZE GAME . 12SPRITES – BASIC WALL, PERSON & GOAL. 12OBJECTS – BASIC WALL, PERSON & GOAL . 12EVENTS/ACTIONS – PLAYER MOVEMENT . 12ROOMS – MAZE 1 . 14LESSON 4 – MAZE GAME PART 2 . 15SPRITES – DIAMONDS & 3-D WALLS . 15SOUNDS – MUSIC & SOUND FX . 16BACKGROUND – ROOM & SPLASH BACKGROUND . 16FONTS – SCORE FONT . 17OBJECTS – DIAMONDS & 3-D WALLS . 17CONTROLLERS . 20ROOMS – SPLASH PAGE . 21LESSON 5 – MAZE GAME PART 3 . 24SPRITES – MONSTERS, BOMBS & BLOCKS . 24SOUNDS – OTHER SOUND FX . 25OBJECTS – MONSTERS, BOMBS & BLOCKS . 26MONSTER COLLISIONS. 27THE BLOCK. 28MONSTER MOVEMENT . 29THE HOLE . 31THE BOMB, TRIGGER & EXPLOSION . 31PLAYER SPRITE UPDATE . 33SOUNDS - LIFE . 33OBJECTS – PLAYER & LIFE . 33ROOMS – ADDITIONAL . 34LESSON 6 – COMPLETING THE MAZE GAME . 36SPRITES – ONE RING TO RULE THEM ALL . 36GAME INFORMATION . 371 P a g e

Game Maker: Maze TutorialWHAT IS GAME MAKER?Game Maker is a program that can be used to create games quickly and easily, and without the need to learn aprogramming language. Although the program allows you to create a game using the Game Maker scriptinglanguage (GML), it is possible to create a game without using any programming code.Game Maker works by using a series of events and actions to perform certain tasks in the game. An example ofthis could be that when the left arrow key on your keyboard is pressed (event), a player on the screen will moveleft (action). A summary of all the Game Maker events and their primary function is included after the finallesson.The following tutorials are based on the official PDF files available on the St Peters Intranet as well as from theofficial Game Maker website. They have been modified slightly to make them easier to follow and understand.Before You StartYou will need to copy the Game Maker folder from the S:/Resources directory to your home (H:) drive.GAME MAKER SCREENAfter you start Game Maker the following screen should appear. Click on the Continue Using the Lite Editionbutton.2 P a g e

Game Maker: Maze TutorialIf you are starting Game Maker for the first time it will be in Basic Mode. You will need to switch to AdvancedMode as it has additional options that you will need a little down the track.To change to Advanced Mode, click on the File menu and select Advanced Mode.The main components used to create games in Game Maker include the This can be an image or a series of images such as animated gifs. Sprites containadditional properties such as transparency, width, height, bounding box, collisiondetection.sprsprPlayerObjectsThese are the ‘living' actors that are given behaviours which respond to events. Forexample, the arrow keys (events) will initiate their movement across the screen(actions).objobjPlayerSoundsThis can include sound fx (e.g. bouncing ball, laser shot) or background music forthe game. Game Maker allows the mp3, midi or wav format.sndsndMusicBackgroundsThese are used to add background images to the game. This background can eitherbe static (still) or animated.bgrbkdRoomRoomRooms are the stage where the objects ‘act'.--The other components of the Game Maker screen (paths, scripts, time lines) are used in the Advanced Mode.They will not be needed at this stage of the tutorial.3 P a g e

Game Maker: Maze TutorialLESSON 1 – THE CLOWN GAMEYou are going to create a simple game that involves using your mouse to click onto a clown that is movingaround the screen.Resource FilesThe files needed for this tutorial are located in the Lecture Resources/Resources 2 directory in the Game Makerfolder that was copied earlier.SPRITES - CLOWN1. Create a new Game Maker file (File New) then save as CLOWN. Remember to save the file every fewminutes.2. You will need to add a number of sprites for this game. To do this right-click on the Sprites folder and selectCreate Sprite.4 P a g e

Game Maker: Maze Tutorial3. Click on the Load Sprite button and select the clown.bmp file from the Resources 2 folder. Ensure that theRemove Background box is checked (this will make the background transparent) then click Open.Type sprClown in the Name box then click OK.4. Repeat the last two steps and load the wall image using an appropriate sprite name, e.g sprWall.5 P a g e

Game Maker: Maze TutorialBACKGROUND – CLOWN5. Right-click the Backgrounds folder and select Insert Background.6. Click on the Load Background button and select the background.bmp file then click Open.Type background in the Name box then click OK.SOUND – BOUNCE7. Right-click the Sounds folder and select Insert Sound.8. Click on the Load Sound button and select the bounce.wav file then click Open. Type sndBounce in theName box then click OK.9. Repeat the last two steps for the click.wav and music.mid files using appropriate sound names, e.g. sndClick,sndMusic.OBJECTS – WALL & CLOWN10. Right-click the Objects folder and select Insert Object.11. Click on the Object Selection buttonand select sprWall. Type objWall in the Name box and tick theSolid and Visible checkboxes then click OK.6 P a g e

Game Maker: Maze Tutorial12. Repeat the last two steps for the sprClown sprite but do not make it solid.Events/ActionsAttaching events and actions to objects gives ‘life’ or interactivity to the game. An object might react to anevent (such as a collision with the wall) and it’s re-action might be that it bounces back off the wall.There are many events and actions that can shape your game. Rather than explain the function of each event andaction available in Game Maker, you will learn some of these as you construct the Clown game. Use the Helpmenu in Game Maker if you wish to learn a little more about them.CREATE EVENT – THE CLOWN13. Ensure that the objClown object is active then click the Add Event button and select Create.7 P a g e

Game Maker: Maze Tutorial14. In the Main1 action list select the Play a Soundaction. Select the sndMusic sound file and set the loopvalue to true. This will cause the music file to repeatforever. Click OK.15. In the Move action list select the Move Fixedaction. Click all 8 directional buttons. Don’t includethe centre direction as this will stop the object frommoving. Set the speed to 4 (you can change this to ahigher value if you think the clown is moving tooslowly) then click OK. Note: By selecting the 8different directions, Game Maker will randomlychoose which direction to move at the start of thegame.16. To make the game less predictable we will add an alarm clock. In the Main2 action list select the Set Alarmaction. Set the number of steps to 50 and the in alarm no to Alarm 0.8 P a g e

Game Maker: Maze TutorialALARM EVENT – THE CLOWN17. Click the Add Event button and select Alarm then Alarm 0.18. From the Move action list add the Move Fixed19. From the Main2 action list add the Set Alarmaction. Click all 8 directional buttons and set the speed action. Set the number of steps to 50 and the in alarmto 0 and check the relative box then click OK.no to Alarm 0.COLLISION EVENT – THE CLOWN HITS A WALLEnsure that the objClown is still open 20. Click the Add Event button and select Collisionwith objWall event. In the Move action list select theBounce action. Accept the default settings and clickOK.9 P a g e21. In the Main1 action list select the Play a Soundaction. Select the sndBounce sound file and set theloop to false (this will play the file only once). ClickOK.

Game Maker: Maze TutorialMOUSE EVENT – HIT THE CLOWN22. Click the Add Event button and select Mouse then Left button. In the Main1 action list select the PlaySound action. Select the sndClick sound file and set the loop to false then click OK.23. In the Score action list selectthe Set Score action. Set the newscore value to 10 and check theRelative box (this will ensure thatthe score keeps accumulating by 10points) then click OK.24. In the Move list, add the JumpTo Random action and set bothsnap options to 0.25. In the Move list add the MoveFixed action. Click the middle(stop) directional button, set thespeed to 0.5 and check the Relativebox (this will ensure that the speedof the clown gradually increaseseach time you hit it) then click OK.Check that the events and actions match the list below:Create10 P a g eAlarm 0Collision with objWallLeft pressed

Game Maker: Maze TutorialROOMS – ENTER THE CLOWN25. Right-click the Rooms folder and select Insert Room.26. Because the size of the sprites are 32 x 32 pixels it would make placing the objects in the room a lot easier ifthe Snap x and Snap y values were set to 32 (located at the top of the room dialog).27. Click on the background tab then click the object selection buttoncreated earlier.and select the background that was28. It is now time to add the objects that will form the basis of the clown game. Click on the Objects tab thenclick the object selection button and select the objWall object.29. Use the left mouse button to place the wall around the boundary of the room. If you make a mistake use theright-mouse button to remove the object from the Stage.30. Click the object selection button and select the objClown object and place one instance in the middle of theroom.31. Save the file then press the Run Game11 P a g ebutton to play and test the game.

Game Maker: Maze TutorialLESSON 2 – THE MAZE GAMEYou are going to create a maze game that involves using your keyboard to move your player around a numberof rooms.Resource FilesThe files needed for this tutorial are located in the Lecture Resources/Resources 3 directory in the GameMaker folder that was copied earlier.SPRITES – BASIC WALL, PERSON & GOAL1. Create a new Game Maker file (File New) then save as MAZE. Remember to save the file every fewminutes.Add the following sprites:FileNameRemove oal.gifsprGoalYesOBJECTS – BASIC WALL, PERSON & GOAL2. Create objects for all the sprites above (objWall, objPerson, objGoal). Make sure that the objWall object issolid.EVENTS/ACTIONS – PLAYER MOVEMENT3. Ensure that the objPerson object is active (i.e. double-click objPerson) then click the Add Event button andselect Collision, objWall.12 P a g e

Game Maker: Maze Tutorial4. In the Move action list select theMove Fixed action. Click themiddle directional button (stop)then click OK. In other words,when the player hits a wall it willstop moving. Therefore, it is notimportant what value the speed is.6. In the Control action list selectthe Check Grid action. Type thevalue 32 into both the snap hor andsnap vert box. This action willmake sure that the player doesn'tget stuck anywhere in the maze ifthe sprite isn't aligned properly.7. In the Move action list select theMove Fixed action. Click the leftbutton and set the speed to 4 thenclick OK.5. Click the Add Event button andselect Keyboard, Left .8. Using the table below to add the remaining Events and Actions for the objPerson object:EventAction ListControlKeyboard right MoveControlKeyboard down MoveControlKeyboard up ActionCheck GridMove FixedCheck GridMove FixedCheck GridMoveSettingssnap hor: 32; snap vert: 32Direction - Right button; Speed - 4snap hor: 32; snap vert: 32Direction - Down button; Speed: 4snap hor: 32; snap vert: 32Direction: Up button; Speed: 4Move FixedControlKeyboard no key Check GridMoveDirection - Stop button (middle); Speed: 4Move Fixed13 P a g esnap hor: 32; snap vert: 32

Game Maker: Maze Tutorial9. The events/actions for the objPerson object will allow the user to use the arrow keys to move the player up,down, left and right. The no key event is included so that when the user releases any of these keys the playerwill stop moving.10. Open the objGoal object and add the following events/actions:EventAction ListMain1Main1ActionIf next room existsGo to next roomSettings-Transition (optional)Collision objPersonControlMain 2ElseRestart game--11. The events/actions for the objGoal object will allow the player to move to the next room (if it exists) once itcollides with objPerson object.ROOMS – MAZE 112. Add a new room (right-click on Rooms folder, Add Room)13. Click the settings tab and change the room size to 480 x 480, caption to Simple Maze and the snap x andsnap y values to 32.14. Click the objects tab then select the appropriate object to create the following room using the objWall,objGoal and objPerson objects.15. Save the game and test.14 P a g e

Game Maker: Maze TutorialLESSON 4 – MAZE GAME PART 2This is a continuation of the maze game created in the last tutorial. Open the maze file from lesson 3. In thislesson, you will create an additional room in which you will need to collect diamonds before you can proceed tothe next level. You will adjust the walls of the room using different sprites so that it looks a little more realistic.Resource FilesThe files needed for this tutorial are located in the Lecture Resources/Resources 3 directory in the GameMaker folder that was copied earlier.SPRITES – DIAMONDS & 3-D WALLS1. Add the following sprites:FileNameRemove Backgroundwall corner.gifwall cornerNowall horizontal.gifwall horizontalNowall vertical.gifwall verticalNodiamond.gifsprDiamondYes2. You will also need to create a sprite manually. Right-click the Sprites folder and select Add Sprite.3. Click the Edit Sprite button then click the File New to create a new sprite. Set the width and height to 32then click OK. Double-click the transparent sprite that should now be visible on your screen. This will take youinto the Image Editor window.4. Using the Fill Bucket15 P a g eselect a red colour from the palette then click on the image.

Game Maker: Maze Tutorial5. Click the close and save buttonBackground box.twice then name the sprite sprDoor and uncheck the RemoveSOUNDS – MUSIC & SOUND FX6. Add the following sounds:FileNamebackground alBACKGROUND – ROOM & SPLASH BACKGROUND7. Right-click the Backgrounds folder and select Add Background.8. Click on the Load Background button and select the background2.bmp file, type bkgd main in the namebox then click OK.9. Create a Splash Page image background similar to the example below using Fireworks or Photoshop. Theimage size should be 550 x 500 pixels. When you have finished, save the image as background start (theformat can be either a gif, jpeg or png file).10. Right-click the Backgrounds folder and select Add Background.11. Click on the Load Background button and select the start background file. Type background start in thename box then click OK.16 P a g e

Game Maker: Maze TutorialFONTS – SCORE FONT12. Right-click the Fonts folder and select Add Font. Modify the settings as shown below:OBJECTS – DIAMONDS & 3-D WALLS13. Create objects for each of the sprites created earlier using the names objCor, objHor, objVer, objDiamondand objDoor. Make all wall objects solid. Use the image as a guide to replace the old wall with the new wallobjects 17 P a g e

Game Maker: Maze Tutorial14. Set the Parent property to objWall as shown below. Because we want all the walls to behave like theobjWall object that was created in the last lesson, setting the parent property will save time as we don't have tocreate a collision event for each wall type. Make sure that the other wall types have the objWall as the parent.15. The objDiamond object is going to be used to accumulate points in the maze. Using the table below createthe following events/actions for the objDiamond object:EventAction ListScorecollision, objPersonMain1Main1ActionSet the scorePlay soundDestroy instanceSettingsnew score: 10; relativesound: sndDiamond; loop: falseapplies to: selfEvents/Actions SummaryThe sequence of events and actions will result in a score of 10 being added each time a diamond is collected.The sndDiamond sound will then be played followed by the removal of the diamond from the screen.18 P a g e

Game Maker: Maze Tutorial16. Open the objGoal object. It should still have a list of actions that you added in the previous lesson. Using thetable below add the following actions to the collision with objPerson event:EventAction ListActionSettingsScorenew score: 100relativeMain1sound: sndGoal, loop: falseMain2milliseconds: 1000Main1ControlMain1collision, objPersonTransition: fade out and inControlControlMain2Congratulations!Scorenew score: 500relativeScoreMain2ControlThe final list of actions should look like the diagram below.19 P a g e

Game Maker: Maze TutorialEvents/Actions SummaryThe sequence of events and actions will result in a score of 100 being added followed by the sndGoal soundbeing played and a pause of 1 second. The game will then check if another room exists. If the room exists thenthe game will proceed to that room. Otherwise, a congratulations message will appear, a score of 500 will beadded, the highscore table will be shown followed by the game restarting. Note the use of the start and endblock. The start and end block actions must be used each time an If action (e.g. If the number of instances is avalue) is followed by two or more other actions (e.g. Play sound and Destroy instance actions).17. Using the table below add the following events/actions for the objDoor object:EventAction ListControlControlcollision, objPersonMain1Main1ControlActionIf the number of instances is a valueSettingsobject: objDiamond; number: 0; operation: Equal toStart of blockPlay soundDestroy instancesound: sndDoor; loop: falseapplies to: selfEnd of blockEvents/Actions SummaryThe sequence of events and actions will result in the objDoor object being used to block the objGoal object inthe maze. The door will open (i.e. it will disappear) and the sndDoor sound played after all the diamonds havebeen collected by the player, i.e. when the number of diamonds is equal to 0.CONTROLLERSControllers are objects that perform actions based on events but are not actually seen by the player and thereforedo not require any sprites to be created. The maze game requires two controllers: the first controller will be usedat the start of the game (to reset the score amongst other things) while the second one will be used in every room(e.g. to keep track of the score, etc.).18. Right-click the Objects folder and select Insert Object. Type controller start in the Name box and uncheckthe Visible box.20 P a g e

Game Maker: Maze Tutorial19. Using the table below add the following events/actions for the controller start object:EventAction ListActionnew score: 0ScoreMain1CreateSettingsshow score: don't show; show lives: don't showScorenew lives: 3sound: sndMusic; loop: trueKeypress any key Main1transition: fade out and inEvents/Actions SummaryThe sequence of events and actions will result in the score being reset to 0, background music being played andthe scores being hidden. When a key is pressed the game will move to the next room.20. Right-click the Objects folder and select Insert Object. Type controller main in the Name box and uncheckthe Visible box.Using the table below add the following events/actions for the controller main object:EventDrawAction ListActionSettingsDrawfont: score fontDrawcolor: redScorex: 0, y: 0, caption: Score; Relativetext: Lives; x: 90; y: 0; relativex: 150; y: 0; sprite: sprHeartEvents/Actions SummaryThe sequence of events and actions will result in the controller being used to set the font colour and position ofthe score.ROOMS – SPLASH PAGE21. Add a new room (right-click on Rooms folder, Add Room)22. Click the settings tab and change the room size to 480 x 512, caption to A-Mazing! , the snap x and snap yvalues to 32 and room start in the Name box.23. Click the background tab then click the add21 P a g ebutton and select the background start background.

Game Maker: Maze Tutorial24. Click the objects tab then select the controller start object and place anywhere in the room. The objectappears as the following symbolin the room.25. Open room1 and modify the room size to a height of 512. Place the controller main object in the bottomleft corner.26. Add a new room (right-click on Rooms folder, Add Room) to create room2.27. Click the settings tab and change the room size to 480 x 512, caption to Collect all the diamonds! , the snapx and snap y values to 32 and type room2 in the Name box. Place the controller main object in the bottom leftcorner as well as the other objects so that it looks like the example below.22 P a g e

Game Maker: Maze Tutorial28. Re-order the rooms by dragging the room up or down so that they are in the following order: room start,room1, room2.29. Save the game and test. If you are finding that the player gets stuck when it hits the wall, you will need toopen the each of the sprites and uncheck the Precise Collision Checking option.23 P a g e

Game Maker: Maze TutorialLESSON 5 – MAZE GAME PART 3This is a continuation of the maze game created in the last tutorial. Open the maze file from lesson 4. In thislesson, you will add the extra challenge of trying to avoid monsters in the maze. You will also use bombs toexplode walls.Resource FilesThe files needed for this tutorial are located in the Lecture Resources/Resources 3 directory in the Game Makerfolder that was copied earlier.SPRITES – MONSTERS, BOMBS & BLOCKS1. Add the following sprites:FileNameRemove Backgroundmonster1 nice.gifsprMonsterlrYesmonster2 nice.gifsprMonsterudYesmonster3 sprExplosionYesblock.gifsprBlockYesOpen the sprMonsterlr to view the image. Click on the next subimage button. You should notice that thesprite is made up of a number of different images (similar to an animated gif). We will take advantage of this alittle later in the tutorial as we will be able to display the relevant view of the monster sub-image depending onwhich direction it is going. Look at the other sprites to see their sub-images.2. You will also need to create a new sprite manually. Right-click the Sprites folder and select Add Sprite.3. Click the Edit Sprite button then select the File menu and New. Enter 32 for both the Width and Heightvalues then click OK.24 P a g e

Game Maker: Maze Tutorial4. Double click on the blank sprite. This will take you into the Image Editor window. Using the FillBucketselect a green colour then click on the image.5. Click the close and save buttontwice then name the sprite sprHole and uncheck the Remove Backgroundbutton. You should now have the following sprites:SOUNDS – OTHER SOUND FX6. Add the following ehole.wavsndHolepush.wavsndPushYou should now have the following sounds. Note: the names might be slightly different 25 P a g e

Game Maker: Maze TutorialOBJECTS – MONSTERS, BOMBS & BLOCKS7. Create objects for the new sprites from the previous step. Ensure you name the various objects using thenames example below.SpriteObjectsprM

Game Maker: Maze Tutorial 2 Page WHAT IS GAME MAKER? Game Maker is a program that can be used to create games quickly and easily, and without the need to learn a programming language. Although the program allows you to create a game using the Game Maker scripting language (GML), it is possible to create a game without using any programming code.