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

Creating a moving platform


We've now seen both static and dynamic physics objects in GameMaker, but what happens when we want the best of both worlds? Let's take a look at how to create a platform that can move and affect other objects via collisions but is immune to said collisions.

Getting ready

Again, we'll be using our existing physics environment, but this time, we'll need a new object. Create a sprite that is 128 px wide by 32 px high and assign it to an object called obj_platform. Also, create another object called obj_kinematicParent but don't give it a sprite. Add collision events to obj_staticParent, obj_dynamicParent, and itself. Make sure that there is a comment in each event.

How to do it

  1. In obj_platform, add a Create event.

  2. Drag a code block to the Actions box and add the following code:

    var fixture = physics_fixture_create();
    physics_fixture_set_box_shape(fixture, sprite_width / 2, sprite_height / 2);
    physics_fixture_set_density(fixture, 0);
    physics_fixture_set_restitution(fixture...