Monday, October 7, 2013

Make Your Own Games On The Game Maker

Game Maker makes it relatively easy to create video games.


Game Maker is a development tool, created by YoYo games, which makes it easier for non-programmers to create their own video games. However, developing games can be a complex task, even in Game Maker, so the age-old classic Pong is a great place to start your game development career.


Instructions


1. Create your sprites (or game images). You will need to produce a total of three. Right click the word "Sprite" in the objects tree on the left, and click "Create Sprite" from the menu that pops up. Change the name of this first sprite from "sprite1" to "paddle" and click the "Edit Sprite" button.


This opens the sprite editor. Click "File" and "New" to create a new frame of the sprite animation. Set the "width" option to 64 and the "height" option to 32. Double click the image that is created.


You will be given an interface that looks a great deal like the interface of Microsoft Paint or Adobe Photoshop. Use the paint bucket tool to color the entire image green (or any other color you prefer).


Click the green check marks in the menu to save your work and return to the base game maker window.


Use this same procedure to create two more sprites: one named "ball" and another named "wall." Draw the wall to be all red using the paint bucket, and draw the ball as a circle using the circle tool. Yellow is a good color for this, but you can use any you like.


2. Create your objects. You'll need to create a total of four.


The first will be the player's paddle. Right click the word "Object" from the objects tree and choose "Create Object." Change the name so that it reads "playerOne." In the sprite option box just below the name, click the small blue button that looks like a pop-up window with a mouse over it. This will pop up a list of all your sprites and allow you to select one that will be the graphic for this object. Select "paddle." Finally, ensure that the boxes for "Visible" and "Solid" are both checked and click "ok."


Follow the same procedure to create a new object named "aiPlayer." Assign it the paddle sprite as its graphic.


Again, create another new object, name it "ball" and assign it to use the ball sprite.


Finally, create a final object and name it "wall." Assign it to use, you guessed it, the wall sprite.


3. Program the user controls. For this version of Pong, things will stay simple. The player's paddle will follow the mouse around the screen. To start programming, double click the playerOne object you just created.


Under "events," click the "Add Event" button. Select the command "Step" as your event trigger. This tells Game Maker that you want an event to occur on every single frame of animation, while the game is running. On the far right side of the window, you will see a list of tabs. Choose the "control" tab. Find the icon that looks like a sheet of paper under the "code" section and drag it into the "Actions" window with your mouse.


An entry should be added to the actions window that reads "Execute a piece of code." Double click this and you'll be presented with a small text-editor. Type the following in:


self.x = mouse_x


Click the green arrows and ok boxes to save your work and close the code editor and playerOne object.


4. Program the computer player. Double click the aiPlayer object from your object list and follow the same procedure as step 3 with only one alteration. Instead of inserting the code from step 3, insert the following code into the text editor:


self.x = ball.x


This will give us a particularly challenging Pong computer player. The computer's paddle will always track the location of the puck, no matter where it goes.


5. Program ball. The ball is the most complicated part of the entire game.


Double click the ball object to open its object properties, click the "add event" button and select the "Step" option.


Under the "move" tab on the right side, there will be an icon that looks like an arrow bouncing off of a wall. Drag that into the actions box and it will appear in the list, along with the explanation "Bounce against solid objects."


Next, go down to the "control" tab and add another "Execute a piece of code" action, by dragging the icon that looks like a sheet of paper into the actions list. Insert the following code:


if (ball.y > room0.room_height) {


show_message("You lose!")


game_end()


}


if (ball.y > 0) {


show_message("You win!")


game_end()


}


This is a little more difficult than the code before. It is saying: "if the ball ever leaves the room at the bottom, then the player has lost. Show him a message, and end the game. If it ever leaves the room at the top, then the player has won. Show him a message, and end the game."


The ball has been programmed, but there is only one small flaw: it doesn't start moving!


Click the "add event" button and select the "Create" option. Go to the "move" tab and drag the icon that looks like a bunch of red arrows pointing outwards.


Click an arrow to choose a starting direction you like and set a "speed" of 5.


Click the green check marks to exit back to the basic Game Maker window.


6. Create a room. Right click the "Rooms" option in the object tree and choose "Create Room." Click in the object's box and select the wall object from the pop up. Use your left mouse button to draw a wall on the left and right sides of the level.


Click the object's box again and select the ball. Place it in the middle of the level.


Again, click the object's box and select the "playerOne." Place it at the bottom of the level.


Finally, click the object's box and select the "aiPlayer." Place it at the top of the level.


7. Press the green arrow to test your game and have fun!