Chapter 15 Combat Systems and Loot

Hands-on Rust — by Herbert Wolverson (100 / 120)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Wrap-Up | TOC | Designing Data-Driven Dungeons 👉

Writing spawn functions for every item, monster, or other entity you think up can take time, and waiting for your game to recompile so that you can test those new ideas is not fun. But don’t worry, there’s something that can help: data-driven design.

With data-driven design, instead of hard-coding entities into your game’s source code, you specify these entities in a data file, which gets read when the game generates a new level. This type of setup allows you to rapidly test new ideas.

Terminology Time

INFORMATION

A data-driven design loads as much data as possible from data files, and then it uses that data to populate the game entities. This is useful if you’re working with a team of designers and developers, because team members can change the game without having to learn Rust.

An ECS is data-oriented since it focuses on storing data in memory and providing efficient access to it.

In this chapter, you’ll move your spawning functionality into a generic function that will read your entity definitions from a file and create components using that data. You’ll also add varying damage levels to monsters and weapons, and you’ll extend the combat system to use the new values — providing a much more varied game, with more tactical…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.