Designing Data-Driven Dungeons
Your game’s entities have a lot in common. For example, they all have a name, starting position, render information, and game stats. Rather than use a custom spawn function for every entity in the game—which is what you’re doing now—you’ll create a common spawn function that reads the game’s data file and adds components using the values found in that file. But first, you need a data file and an appropriate format.
This book will use RON (Rusty Object Notation) files to store your game definition.[65] RON is similar to JSON and other structured data formats, but it’s designed to look like Rust.
Create a new file named resources/template.ron and paste the following game definition into it:
| Templates( |
| entities ... |
Get Hands-on Rust now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.