Finding the Amulet of Yala

You win the game when you collect the Amulet of Yala. Yala is an acronym for “yet another lost amulet,” a gentle poke at Nethack’s—and its many derivatives—plot.

Spawning the Amulet

You’ll use two new tag components to denote the amulet:

 #​[​derive​(Clone, Copy, Debug, PartialEq)]
 pub​ ​struct​ Item;
 
 #[derive(Clone, Copy, Debug, PartialEq)]
 pub​ ​struct​ AmuletOfYala;

The Item component denotes that an entity is an item. It doesn’t move or have health, but it should still appear on the map. You’ll add further support for items in Chapter 13, Inventory and Power-Ups. The AmuletOfYala tag indicates that the tagged item is the item that wins the game.

The amulet also ...

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.