game it
play

GAME:IT Bouncing Ball Objectives: Create Sprites Create Sounds - PowerPoint PPT Presentation

GAME:IT Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game All games need sprites (which are just pictures) that, in of themselves, do nothing. They are the elements that


  1. GAME:IT Bouncing Ball Objectives: • Create Sprites • Create Sounds • Create Objects • Create Room • Program simple game

  2. All games need sprites (which are just pictures) that, in of themselves, do nothing. They are the elements that make up the game parts. The sprites are later turned into objects (which can be programmed). Backgrounds are just that — they are what you see in the background. Backgrounds are colors, or textures, or even pictures. The backgrounds are later used as part of the rooms. Sounds are files (usually .wav files) that add another dimension to the games. They are used directly in the programming. Rooms are the “playing fields” for the games. If you want to change the “playing field”, you change the room. Rooms can be changed to different sizes and detail.

  3. Creating a New Game Where do I start? When starting a new game, typically you create the sprites & backgrounds first. The objects are then created from the sprites. Objects are important because they can be programmed to do things (sprites cannot). Rooms are created next because objects and backgrounds are needed to create the rooms. When the room is set up, programming the events and actions of the objects can take place and be tested for errors. If you know what sounds you are using, they can be created before programming starts or added later to enhance the game.

  4. Your first game will demonstrate a few of the elements of Game Maker. The game will involve a ball bouncing around the room and making a sound when it hits the wall.

  5. Your finished game will have (1) a smiley faced ball, (2) a red border, and (3) a lime green background.

  6. The first step is to create your wall and ball “sprites” 1. Click the Create a Sprite icon 2. Enter the name of the sprite — in this case — spr_ball. IT IS IMPORTANT TO NAME THINGS AS INSTRUCTED 3. You can either create your own sprite or load a sprite from a file. In this game, you are going to load a pre-existing sprite, so click the Load Sprite button.

  7. 4. Find the folder that contains your Game 1 Resources and select the ball image and click Open. ***GET THIS FILE PATH FROM YOUR TEACHER*** 5. Once the ball is loaded, click the OK button to save this sprite. 6. Now follow the same steps to create the wall sprite, naming it spr_wall

  8. Next you are going to create a sound 7. Click on the Create a 8. Name the sound snd_beep Sound icon 10. Click “OK” 9. Click the Browse Folder icon to load the beep.wav file from the Game 1 Resources folder to save

  9. By the way . . . . Why is it important to carefully label sprites, sound, backgrounds, rooms, and objects? It’s just GOOD programming— it saves time later in searching for mistakes or making changes to your game. It only takes a few seconds to type in something that could cause minutes/hours of frustration. NAME EVERYTHING EXACTLY AS INSTRUCTED IN OUR LESSONS What are good examples? Spr_ball, spr_wall, snd_beep, bckgd_desert, obj_plane What are BAD examples? Spr01, sound1, background, plane (is it a sprite or object?)

  10. Next, you will create objects. But I don’t understand— we created sprites -- they look the same? The difference is sprites are just pictures, but objects can be programmed in Game Maker. How to create objects: 11. Select the Create an Object icon 12. Name the Object obj_ball 13. You need to assign a sprite to the object. Do this by clicking the list icon, and select spr_ball from the list of available sprites

  11. The objects have additional attributes that need to be discussed – visible & solid ? What is visible? Most items in your games will be visible but occasionally you will need special objects to be invisible (like walls and floors). Even though an object is invisible, they can still be programmed for other objects to collide with for points or to bounce off of. You will learn more about this as we go through the lessons ? What is solid? Solid means you can collide with or bounce off of an object. If an object is not solid, other objects can pass right through. 14. Make sure both Visible and Solid are checked. Click “OK” to finish creating the ball object. 15. Follow the same steps to c reate the wall object – name it obj_wall and assign it the spr_wall.

  12. Next —we create our first “room” 16. Click the Create a Room icon 17. Select the Backgrounds tab 18. Select a color by clicking in the color area to select the background color from the pop-up menu. 19. Click OK to save that color

  13. To add objects to the room: 20. First, we need to make sure the Snap is set to X = 16 and Y =16. 21. Next, select the objects tab 22. Click the list icon and choose obj_ball from the submenu that appears and place the ball somewhere in the middle of the room by clicking your left mouse where you wish to place the ball.

  14. 23. Next, click the List Icon again and select the obj_wall. Click into each square around the perimeter of the room to add the wall. Left mouse adds (or moves) the object. HINT: Click the Left Mouse and drag while hold down the Shift + Ctrl keys can add multiple objects quickly. *Just be very careful where you drag.* NOTE: There is a visual that shows which object will be placed when clicking into the room

  15. If you place something in the wrong spot, right click on that object and select delete from the menu that appears.

  16. Time to Program! The actual programming occurs in the OBJECTS we have created: obj_ball and obj_wall. With the room set up and the objects in the room, what do we want the ball to do? A) Bounce off the walls B) Make a “beep” when it hits the wall. In this case, all the programming takes place in the obj_ball.

  17. 24. Open the Object Properties window for obj_ball by double clicking it in the side menu. 25. Click on the “Add Event” button

  18. What are EVENTS? Events are discreet moments in the game loop where things are made to happen based on what you have programmed for them. Here is a description of the different events: Create Event This event happens when an instance of the object is first created, and is the very first thing that happens within an instance placed in the room. This event is the ideal place to initialize variables, start Timelines, set paths etc... and do anything else that generally only needs to be done once or only when an instance first appears in the room. Destroy Event: This event is the very last event to be executed when an instance is destroyed. It is often overlooked when adding behaviors to objects, but it can be very useful, for example by creating explosion or particle effects when an enemy is killed, or for re-spawning a new instance of the object in another part of the room, or even for adding points onto a score.

  19. Alarm(s): The alarm event is split into 12 sub events, one for each of the possible alarms that can be set in an instance. But what is an alarm? It’s a special event that does nothing unless the alarm has been previously set, and then it will wait until that alarm has counted down to 0 before running the actions or code that you have added into it. Example: Object changes direction every 30 steps. FYI: An Action must reset the alarm.

  20. Step Event: GameMaker:Studio splits time into steps with the room speed defining how many of these steps happen per second. A step is basically the loop that runs constantly with all the events being checked and triggered as necessary while the game runs, so the Step Event is an event that is checked every single step of the game while the instance exists. For most things the standard step event will be fine to use, but sometimes you want a bit more control over what code runs and at what time, so for that you are provided with the begin and end step events.

  21. Collision Event: When 2 objects collide, you want these actions to occur. Example : When bomb collides with plane — create an explosion sprite. Keyboard Event: When a player presses a certain key on the keyboard, the actions will occur. You get the action in every step as long as the key is depressed. There is a <no key> event and an <any key> event.

  22. Mouse Event: This would occur when the mouse cursor touches the object. You can select left, right or middle buttons. Other Events: Miscellaneous collection of “special” purpose events. Check the Help Documents for an description of each of them.

  23. Draw Event: This event is the one that governs what you see on the screen when you run your game, and is split into three separate "sub-events" - the Draw Event, the Draw GUI and Resize Event. Key Press: Only happens once at key press (not continuously). Key Release: Only happens once at key release (not continuously). For more info on all Events, check out the Help Documentation included with Game Maker: Studio.

  24. 26. Select the “Create” event from the Add Events menu. 27. Select “Move Fixed” from the actions menu (Move tab) and drag it into the Actions panel. This will open the Move Fixed window and allow you to set the following variables: • Select the 4 corners of the directions • Enter 5 as the speed. • Leave the relative button unchecked. Click “OK” 28. to save.

  25. 29. Next, click Add Event to select another event. 30. Choose Collision. Assign the collision to obj_wall by selecting it from the pop-up menu.

Recommend


More recommend