Managing Inventory
Items don’t always sit passively on the map, hoping someone will walk onto them. Unless you’re making a Pac-Man style game, it also doesn’t make sense to have items activate when the player walks into them. Instead, let’s allow players to pick up items and carry them in their inventory until they’re needed. This adds strategy to the game, letting players decide when they want to use their precious items.
Items are entities, and they exist on the map because they have a Point component indicating their location. The entity rendering system query requires a Point to draw an item or display its tooltip. You can take advantage of the render system’s query structure by removing the Point component from an item when it’s picked ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access