GameMaker Programming By Example
Table of Contents
GameMaker Programming By Example
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to GameMaker: Studio
Choosing your version
The GameMaker: Studio interface
GameMaker: Studio documentation
An example project
Naming convention – resource prefixes
Drawing the sprite
Creating an object
Coordinate planes in GameMaker
Creating a room
Testing your game
Summary
Review questions
Quick drills
2. Your First Game – Escape the Dungeon
Creating your Escape the Dungeon game
The playable character
The sprite
The object
Walls
Enemies
Making your enemies move
Damaging the player
Making the player and enemies shoot
Making the player shoot
Making the enemies shoot
More resources
Backgrounds
Sounds
Keys and locks and advancing to the next room
Summary
Review questions
Quick drills
3. Introducing the GameMaker Language
Remaking Escape the Dungeon in the GML
Remaking the sprites
Remaking the player object
Understanding the four events
Starting to code your player object
Making the player move
Changing the subimage
Collisions
Coding the enemies
Random seeds
Health and lives system
Displaying health and lives
Invincibility
Shooting
Sounds
Keys and locks
Scripts
Summary
Review questions
Quick drills
4. Fun with Infinity and Gravity – An Endless Platformer
Creating an endless platformer
Bouncing and movement
Death and enemies
Random spawning
2D arrays
Menus and textboxes
Menus
Textboxes
Summary
Review questions
Quick drills
5. Saving and Loading Data
Putting in a scoring system
Saving and loading a highscore
INI file encryption
Customizable controls
Saving control configurations
Summary
Review questions
Quick drills
6. A Multiplayer Sidescrolling Platformer
Sprite animation
Spritesheet importing
Programming the movement
Making your scrolling platformer scroll
Client/server multiplayer networking
Networking terminology
Printing the server's IP address and port on a screen
Creating the actual server
Our Asynchronous Networking event
Connection
Disconnection
Handling data
Our data handling script
The client in your client/server system
Integrating Xbox gamepad support
Legacy gamepad support
Modern gamepad support
Summary
Review questions
Quick drills
7. Programming a Scrolling Shooter
Creating the main ship
Creating the enemies
Parenting in objects
Random enemy spawning
Programming a Boss AI
Particles
Summary
Review questions
Quick drills
8. Introducing the GameMaker: Studio Physics Engine
A physics game
The physics engine in a regular game
Summary
Review questions
Quick drills
9. Wrapping Up
Debugging
Compile-time errors
Runtime errors
The GameMaker: Studio debugger
Debugging functions
Helpful information on GameMaker
Quirks of the GameMaker Language
Unexplained resources
Export modules
Summary
Review questions
Quick drills
Index
GameMaker Programming By Example
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 authors, 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: 1161215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78588-796-3
www.packtpub.com
Authors
Brian Christian
Steven Isaacs
Reviewer
Genevieve Ditangan
Commissioning Editor
Swapnil Khedkar
Acquisition Editor
Vinay Argekar
Content Development Editor
Anish Dhurat
Technical Editor
Tanmayee Patil
Copy Editor
Merilyn Pereira
Project Coordinator
Harshal Ved
Proofreader
Safis Editing
Indexer
Tejal Soni
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
Brian Christian is a high school student with years of experience in programming, much of it focused on game development using GameMaker: Studio via self-teaching the GameMaker Language. He has also worked in C++ and JavaScript programming along with some web development. Additionally, he is knowledgeable in topics such as data formats and interpretation, compilers and interpreters, and networking. Other languages he has used include Intel x86 assembly, Lua, Ruby, and Python.
Brian's spark for computer programming began with an online Ruby course from Codecademy. Since then, he has been fascinated with how computers and the different programming languages worked. Since he wanted to know about this, he taught himself C from the second edition of The C Programming Language book, followed by the more advanced C++ language.
Wanting to try his hand at making advanced games with a language predominantly intended for it, Brian became invested in the GameMaker Language since he'd already been using the drag and drop functionality, but found it limiting. He spent a lot of time learning how different parts of the language worked and how to use them.
Steven Isaacs has been fascinated with technology since the days of his Apple II Plus computer and 300 baud modem. Tinkering, playing MUDs, MOOs, and visiting BBSs occupied much of his free time. In high school, Steven took a programming course in BASIC and created an adventure game as his final project. Many hours were spent in and outside of school working on this game, and it became somewhat of an obsession. It has become abundantly clear that these activities were incredibly influential in the evolution of his professional life. Steven has been teaching since 1992. In addition to teaching, Steven and his wife Cathy Cheo-Isaacs owned Liberty Corner Computing (LCC), a computer training and gaming center with Paul and Sarah Tarantiles. LCC provided innovative summer camps and after school programs offering young people an opportunity to use technology in creative ways. Courses included programming, website design, graphic design and animation, and game development.
Soon after opening LCC, Steven was hired to bring his innovative ideas to William Annin Middle School in Basking Ridge, NJ. At William Annin, Steven taught a number of computer-related courses. His passion for teaching students to create their own games led to an after school club in game design, then a unit in the Gifted and Talented Program. The success of these programs led Steven to develop a full semester 8th grade class in game design an...