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

An interacting world


A lot of game logic has been implemented in the different entities, now we look at functionality that is defined in the World class. You have already seen the collision in the last section.

Cleaning everything up

During the game, entities are destroyed in battle, and have to be removed from the scene graph. We do not remove them instantly. Once in a frame, we iterate through the scene graph, check which nodes have been destroyed, and detach them from their parents. To find out whether a node has been destroyed, we write the virtual function SceneNode::isDestroyed(). By default, it returns false. A derived entity may specify a condition under which it returns true. Usually, this will be the case when the hitpoints are zero or less (that is, the entity is destroyed).

bool Entity::isDestroyed() const
{
    return mHitpoints <= 0;
}

In addition, we add a virtual function that checks if a scene node should be removed from the scene graph. By default, this is true as soon as...

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}