34,79 €
GameMaker: Studio started off as a tool capable of creating simple games using a drag-and-drop interface. Since then, it has grown to become a powerful instrument to make release-ready games for PC, Mac, mobile devices, and even current-gen consoles. GameMaker is designed to allow its users to develop games without having to learn any of the complex programming languages such as C++ or Java. It also allows redistribution across multiple platforms.
This book teaches you to harness GameMaker: Studio’s full potential and take your game development to new heights.
It begins by covering the basics and lays a solid foundation for advanced GameMaker concepts. Moving on, it covers topics such as controls, physics, and advanced movement, employing a strategic approach to the learning curve. The book concludes by providing insights into complex concepts such as the GUI, menus, save system, lighting, particles, and VFX.
By the end of the book, you will be able to design games using GameMaker: Studio and implement the same techniques in other games you intend to design.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 296
Veröffentlichungsjahr: 2015
Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2015
Production reference: 1151215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-984-9
www.packtpub.com
Author
Brandon Gardiner
Reviewers
Ryan Laley
John M. Walker, PE
Commissioning Editor
Nadeem N. Bagban
Acquisition Editor
Kirk D'costa
Content Development Editor
Siddhesh Salvi
Technical Editor
Madhunikita Sunil Chindarkar
Copy Editor
Rashmi Sawant
Project Coordinator
Nidhi Joshi
Proofreader
Safis Editing
Indexer
Hemangini Bari
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
Brandon Gardiner is a game developer and designer living out his love of video games. Though he started his foray into games through 3D art and level design, he always kept a notebook of ideas for games and game mechanics he wished to see. When he discovered GameMaker: Studio, he found that he could bring these ideas to life.
He is a graduate of the first iteration of the game development program at Toronto's George Brown College. In college, he worked as an artist and designer on several game projects for outside companies, including tie-ins for children's television shows and educational titles. After graduating, he founded MechaBee Studios where, being the sole developer of mobile and PC games, he is a jack of all trades.
He also writes a blog at http://www.gamemakerhq.com, through which he hopes to build a resource for other independent developers. He lives with his wife in Toronto where he is a veteran of the annual Toronto Game Jam (tojam.ca), an active member of the International Game Developers Association.
Ryan Laley is an independent games designer. He has been a lecturer in video games design at South Essex College at further and higher education levels for over 5 years. He has been using GameMaker: Studio professionally during those years, and he continues to develop and publish games using it. He began his teaching career after graduating from university, and since then, he has covered every aspect of games development in his classes, including 2D and 3D.
In his spare time, he independently develops his own games and publishes them himself under the studio name of Friendly Fire games. His most recent projects focus on mobile phone platforms, with his latest release Blobb in 2015. His future projects will continue to expand on mobile platforms and eventually onto PCs.
I'd like to thank Jade for her continued support and allowing games to continue to be more than just a fun past-time, but a career as well.
John M. Walker, PE is a licensed professional engineer in industrial engineering and is currently a licensed full-time teacher in computer science and programing at Cleveland High School in Portland, Oregon. He has been teaching full time for the last 15 years for High School and Regional Professional Higher Ed conferences.
He has worked for more than 20 years as an information technology manager for high-technology firms dealing with systems administration and networking architecture and engineering. His favorite position was director of technology for the Portland Trail Blazers, while designing and constructing the Moda Center.
He has also reviewed GameMaker Essentials, Packt Publishing.
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
Since 1999, GameMaker: Studio has enabled fledgling and experienced developers alike to help create video games quickly and easily. In the years since its initial release (as a program called Animo), GameMaker has grown and evolved into a viable commercial game engine that has helped developers release games for PC, Mac, mobile devices, and even the Microsoft Xbox and Sony PlayStation family of consoles.
During its progression, GameMaker has changed in many ways, adding new features and abilities to be taken advantage of by developers around the world. Though these features may be out of reach for new users, the goal of this book is to familiarize beginners and bring such elements within reach. This book is not just a how-to manual, it is an answer to the question "What can GameMaker do for me?"
By reading this book and completing the recipes therein, you will gain a greater understanding of GameMaker's capabilities as well as start them on the path to unlock their full potential.
Chapter 1, Game Plan – Creating Basic Gameplay, shows you how to create the basic elements of a game.
Chapter 2, It's Under Control – Exploring Various Control Schemes, helps you figure out how to implement user controls for a variety of devices.
Chapter 3, Let's Move It – Advanced Movement and Layout, teaches you more advanced ways to move players and non-player characters alike.
Chapter 4, Let's Get Physical – Using GameMaker's Physics System, introduces you to the physics system and demonstrates how GameMaker handles gravity, friction, and so on. You will also learn how to implement this system to make more realistic games.
Chapter 5, Now Hear This! – Music and Sound Effects, helps you pick up the ins and outs of GameMaker's audio system.
Chapter 6, It's All GUI! – Creating Graphical User Interface and Menus, discusses the most important element of the Graphical User Interface (GUI).
Chapter 7, Saving the Day – Saving Game Data, discusses how GameMaker handles how to save data as well as its various uses.
Chapter 8, Light 'em up! – Enhancing Your Game with Lighting Techniques, helps you understand how GameMaker's surfaces can add lighting effects to your game.
Chapter 9, Particle Man, Particle Man – Adding Polish to Your Game with Visual Effects and Particles, shows you how GameMaker handles particles and how you can draw players in with simple effects.
Chapter 10, Hello, World – Creating New Dimensions of Play Through Networking, teaches you how to create multiplayer games with GameMaker's networking capabilities.
For this book, you will require the following software:
For a detailed platform-specific list of requirements, refer to http://www.yoyogames.com/studio/system-requirements.
This book is intended for GameMaker: Studio enthusiasts who are looking to add more substance and improve their content. If you know your way around the program and have some basic GML skills but want to take them further, then this book is for you.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Create a sprite and name it spr_enemy_patrol."
A block of code is set as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click Add Event, then Other, and select Animation End."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/9849OS_ColorImages.pdf.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we'll cover the following:
GameMaker is a great tool for people interested in various aspects of game development. It can be used to quickly create simple, playable games, or even churn out hits like Hotline Miami and Gunpoint. Want to take part in a game jam? GameMaker can save you hours of coding, and as many headaches. Have a game mechanic you want to visualize? GameMaker is great for prototyping; it can do that. Well, you will have to do the work. GameMaker will just make it faster and easier.
Let's take a look at just how quickly and easily we can make a game using GameMaker's drag-and-drop interface.
Animated sprites can be made by importing frames from a sprite sheet or by creating individual images in a 3rd party program. What happens, though, if you don't have access to these methods? GameMaker includes its own image editor that, while not as versatile as programs like Photoshop, has received some recent upgrades that can help you create some decent animations.
Let's make a player character sprite with a simple walk cycle. If you haven't already, now would be a good time to open GameMaker, start a new project, and create a sprite. Name the sprite spr_player_walk.
Using descriptive names like this allows you to categorize your assets, which makes finding the right asset much easier.
As mentioned before, you can use 3rd party art programs to create your own sprites and import them to GameMaker. If you're more interested in just making something that moves, I've included the files necessary to create an animated sprite; simply load them from sprite properties and you're almost good to go.
With that out of the way, let's look at using GameMaker's built-in Sprite Editor.
The Image Editor comes with another feature that is great for animating your sprites: Onion Skin. Onion Skin allows you to, while working on one frame of an animation, view the following and preceding frames. You can set how many frames you want visible, both backwards and forwards, and use the Onion Skin value to change the opacity of those frames to alter their visibility while working. This can help you paint each form and make the animation more fluid because you can see where you've been and where you're going. A useful addition to this is the Scratch Page. Simply hit the J key to be taken to and from a frame that doesn't actually exist in your animation, but allows you to cut and paste image elements. It's a big help when you want to move separate pieces of an image from one frame to another.
The Scratch Page looks the same as the standard Image Editor window and holds whatever you paste in it.
There you have it; you've animated a sprite for use in a game. That's a great first step, but we're not finished. If you use this sprite on your character it will appear as though he's walking at all times. I don't know about you, but that's not what I want to see in a game. You could animate an idle sprite, which is ideal for a polished look, but we're going to speed this up by using a single-frame idle pose.
Done. You now have a second sprite for a single character.
As we've just seen, it's possible to create fully animated characters without the use of a 3rd party program. While other programs give you many more options not found in GameMaker, such as layers, you still have access to the fundamentals you need to get the job done. The editor is great for pixel art and Onion Skin makes animating a lot smoother by showing you adjacent frames.
Now, we've only made sprites for two states of our character's being: idle and walking right. There are many other sprites you may want to consider if you're looking to build a full game. Think about other games you've played; how many different movements and poses do they incorporate? Walking, running, jumping, rolling, punching, shooting, and so on, you get the idea. When designing a game, any actions you intend for your player character should be listed and planned out because you need to consider just how many sprites you'll need. Will they be animated? Will they look different depending on what direction the player is facing, or can they be mirrored? How long will it take for the animation to play out? These are all important questions, but they get easier to answer with each game you make.
Sprites used for GUI will be discussed in Chapter 6, It's All GUI! – Creating Graphical User Interface and Menus, while sprite-based VFX are used in Chapter 9, Particle Man, Particle Man – Adding Polish to Your Game with Visual Effects and Particles.
There are many different types of games with different visuals and play styles. Some games are devoid of a visible player character but most, especially 2D games, have the player controlling a sprite or 3D model onscreen. We're going to take a quick look at putting a character in front of the player that he/she can control.
You've animated some sprites, but animated sprites won't do you any good without a character to which they can be applied. Create a new object and call it obj_player. Under Sprite, click the menu icon and select spr_player_idle.
We want the player character to move right when the right arrow key is pressed but we don't want him to simply walk right off the screen. How mad would you be if the character you were controlling simply gave up, said That's it, I'm out of here! and disappeared off screen? Sounds like an entirely frustrating experience. Since we don't want this to happen, let's make sure it can't. For that, you'll need to add a variable check before your character goes anywhere.
Under the Control tab, drag and drop Test Variable to the Actions box.We want to test the variable x, which is the player's x coordinate or horizontal position. Since we want to the player to stay on-screen, we'll set the value to room_width-16 and the operation will be less than.Close the Test Variable box and under the Move tab, drag and drop Jump to Position to the Actions box.Set x to 4, leave y as 0, and make sure Relative is checked. If you were to test this out now, your player will begin moving to the right as his walk cycle animation played. The problem is that now it doesn't stop.Add another event but this time choose Key Release <Right>. Add Change Sprite to the Actions box but this time select spr_player_idle from the menu. This time, if you were to run a test, your player would walk right when holding the right arrow key and go back to his idle pose when it is released.These same steps can be repeated for all directions using corresponding keyboard events but you need to take into consideration whether or not you need to mirror the sprites. If you've created separate sprites for each direction you'll simply choose which sprite you'll need at the time. If, however, you've opted to mirror the sprites, you'll need to add one more thing to each key event.
Under the Main1 tab, drag and drop Transform Sprite into the Actions box for each key event (key release events included) and modify the xscale (for horizontal mirroring) or the yscale (for vertical flipping). Setting the value to -1 would flip the image and setting it to 1 would revert it to its original facing. If the image is already facing that way, no change is made. Avoid using the options in the Mirror menu, as these selections alter the image from its present state instead of assigning a value. This would mean that if you hit the left arrow key, and the character was already facing left, he would flip and face right. That would be confusing!This and any other drag and drop function in GameMaker can also be used in code and scripts. In fact, coding them yourself often allows for greater control over how they work.
The movement discussed in this section is quite simple. In this case, you've instructed GameMaker to make your character move left or right and play the walk animation (facing the proper direction) as he goes. Using jump to position allows you to move a character to any point in the screen or, as you did here, move the character relative to its current position, adding the entered values to existing coordinates. Using a negative value would subtract from the current coordinates, causing the character to move in the opposite direction. If you want your character to move up or down you would change the value of y and leave x as 0. I encourage you to play around with the values entered, as this will change the player's speed.
It might seem like this section had a lot of text to set up very simple movement, but I can assure you it is all necessary. This section and the rest of the chapter set up some core ideas that will recur throughout your GameMaker experience and will be explored much further later on.
Several methods of advanced player movement and controls will be demonstrated in Chapter 2, It's Under Control – Exploring Various Control Schemes, and Chapter 3, Let's Move It – Advanced Movement and Layout.
Now that our character can move, logically (or rather, illogically), we want to give him a gun. Though countless games offer projectiles as part of the gameplay, there are a great number of design choices to consider that will ultimately alter the way the player plays. We're going to create simple projectiles right now but later in the book we'll discuss different design choices for creating and controlling gameplay.
We want to create a projectile at our character's location whenever the player hits the Spacebar. On creation of the projectile, we want GameMaker to verify the direction the player is facing and send it flying in that direction. Before GameMaker can check the direction, though, we need to create a variable that tells GameMaker which direction the object is actually facing. It sounds convoluted but in execution it's really fairly simple, so let's begin.
