Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
SFML Game Development

You're reading from  SFML Game Development

Product type Book
Published in Jun 2013
Publisher Packt
ISBN-13 9781849696845
Pages 296 pages
Edition 1st Edition
Languages
Authors (5):
 Artur Moreira Artur Moreira
Profile icon Artur Moreira
 Henrik Vogelius Hansson Henrik Vogelius Hansson
Profile icon Henrik Vogelius Hansson
Jan Haller Jan Haller
Profile icon Jan Haller
Henrik Valter Vogelius Henrik Valter Vogelius
Profile icon Henrik Valter Vogelius
View More author details

Table of Contents (18) Chapters

SFML Game Development
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Making a Game Tick 2. Keeping Track of Your Textures – Resource Management 3. Forge of the Gods – Shaping Our World 4. Command and Control – Input Handling 5. Diverting the Game Flow – State Stack 6. Waiting and Maintenance Area – Menus 7. Warfare Unleashed – Implementing Gameplay 8. Every Pixel Counts – Adding Visual Effects 9. Cranking Up the Bass – Music and Sound Effects 10. Company Atop the Clouds – Co-op Multiplayer Index

Rendering the scene


At one point, we have to reflect about how the game is rendered on the screen. How do we draw all the entities, the scenery, and interface elements (such as a health bar)? A simple option is to have different sequential containers through which we iterate. For each element, we call a possible Entity::draw() function to draw the corresponding entity on the screen. We only have to make sure that objects that appear behind others (such as the scenery background) are drawn first.

Relative coordinates

The sequential rendering approach works well for many cases, but makes it difficult to handle an entity relative to another one. Imagine we have a formation of airplanes, where one is the leader and the rest follows it. It would be nice if we could set the position of the following airplanes dependent on the leader, in the sense of "plane A is located 300 units behind (below on the screen) and 100 units right of the leader" instead of "plane A is located at position (x, y) in...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}