June 2021
Beginner
344 pages
8h 9m
English
If you run around the map, you’ll notice that nothing happens when you hit a monster. Let’s change that by adding collision detection. You’ll write a combat system in Chapter 8, Health and Melee Combat—for now, walking into a monster will remove it from the dungeon.
Collision detection will be its own system. Add a new file to your project, src/systems/collisions.rs. Don’t forget to add mod collisions; to your src/systems/mod.rs file.
Start collisions.rs with a similar pattern:
| | use crate::prelude::*; |
| | |
| | #[system] |
| ① | #[read_component(Point)] |
| | #[read_component(Player)] |
| | #[read_component(Enemy)] |
| ② | pub fn collisions(ecs: &mut SubWorld, commands: ... |
Read now
Unlock full access