Book Image

GameMaker Cookbook

Book Image

GameMaker Cookbook

Overview of this book

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.
Table of Contents (17 chapters)
GameMaker Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding sound emitters and listeners


With its updated audio engine, GameMaker has added the ability to simulate 3D sound. This doesn't mean that you have to make a 3D game to utilize it, however; you can use this feature to add depth (figurative and literal) to your 2D world. Let's take a look at some basics for creating location-dependent audio.

Getting ready

This recipe calls one sound file (I used a 13-second loop of rushing water; it is a public domain sound I downloaded from http://soundbible.com/): a player object (our listener) and emitter object. Give the player and the emitter their own sprites. Though a sprite for the latter isn't necessary, we're going to make it visible so that you have a point of reference when you test it. We'll call the emitter, obj_water, and our player character something crazy such as obj_player. Create a room and place both the objects in it with obj_water near the center.

How to do it

  1. Click on the Create a sound icon and load your audio.

  2. Call the sound object...