Book Image

Libgdx Cross-platform Game Development Cookbook

Book Image

Libgdx Cross-platform Game Development Cookbook

Overview of this book

Table of Contents (20 chapters)
Libgdx Cross-platform Game Development Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The 2D space sound system


Modern games do not simply play sounds and forget about them; they usually feature a full-blown spatial audio system.

Effects have a position in the game, which makes them play differently depending on the camera position. The further away the camera moves from the source, the fainter the effect will be perceived. Moreover, they usually take into account the angle between the camera and the effect so as to produce a stereo effect. Some engines implement really complicated sound models to produce the most realistic results possible.

Not only do these systems play an important role in immersion, they also greatly contribute to gameplay in many occasions. In a stealth game, for instance, it is crucial to know where a sound is coming from as it may hint the position of nearby enemies. You can surely come up with many other examples where sound positioning is relevant to gameplay.

In this recipe, we will cover the full implementation of a simple 2D spatial sound system...