#### Overview of this book

This book is excellent resource for developers with any level of experience of GameMaker. At the start, we’ll provide an overview of the basic use of GameMaker: Studio, and show you how to set up a basic game where you handle input and collisions in a top-down perspective game. We continue on to showcase its more advanced features via six different example projects. The first example game demonstrates platforming with file I/O, followed by animation, views, and multiplayer networking. The next game illustrates AI and particle systems, while the final one will get you started with the built-in Box2D physics engine. By the end of this book, you have mastered lots of powerful techniques that can be utilized in various 2D games.
GameMaker Programming By Example
Credits
www.PacktPub.com
Preface
Free Chapter
Introduction to GameMaker: Studio
Your First Game – Escape the Dungeon
Introducing the GameMaker Language
Fun with Infinity and Gravity – An Endless Platformer
A Multiplayer Sidescrolling Platformer
Programming a Scrolling Shooter
Introducing the GameMaker: Studio Physics Engine
Wrapping Up
Index

## The physics engine in a regular game

The remainder of this chapter will be a small tutorial on how to incorporate physics into a top-down style game, like our first one. We're just going to create a small engine to demonstrate how you would move around a player and get perfect collisions.

So first create a simple player sprite and wall sprite. They can be simple squares or complex shapes if you want. Make sure that you center the origins—it's important for the collisions to work properly.

Now create a player and wall object. Give the wall its sprite, a density of `0`, and a collision shape. If you made the sprite complex (although walls are usually blocky), then select the Shape option and plot a series of points to get a collision shape that matches the wall and then open up the player object. Give the player its sprite and a collision shape. If the player's sprite is complex, then use the Shape option.

Now let's make the player move and stop at the wall. Add a Create event, and set `phy_fixed_rotation...`