January 2016
Beginner
512 pages
12h 35m
English
Let's implement a script serving as artificial intelligence (AI) for a nonplayer character in a simple Dungeons & Dragons game. The engine will periodically execute the script, exposing two objects to it—the creature and the player. The script will be able to query the properties of the player and invoke functions on the creature.
Let's create a new project. We'll start by implementing the C++ class for creatures in our game world. Since both the NPC and player are living entities, we can have a common base class for them. In Chapter 4, Qt Core Essentials, we already had a data structure for players, so let's use that as a base by equipping our entities with similar attributes. Implement LivingEntity ...