[−][src]Module rust_action_heroes::entity
Builder functions for creating entities.
These all follow a repeating pattern:
- Given the World, a Sprite Sheet Handle, and Coordinates for the entitiy/entities.
- Create an entity in the world with that information.
- Each method hard-codes which sprite number that entity has, and the components that entity has.
For my next game I think I'll try to implement some file-based entity specification. There's a lot of boilerplate that doesn't need to be here and the game wouldn't need to re-compile every time I change an entity's component list. Each entity could be specified in RON syntax sorta deal like:
# assets/entities/001.ron
Components([
Transform,
Movable,
Sprite(2),
Position(x, y),
Named(Name::Horizontal),
Holding,
])
Then the entity-loader would iterate over all files in assets/entities/*.ron
and build:
let mut entitybuilder = world.create_entity(); for component in EntitySpec.Components { entitybuilder = entitybuilder.with(component); } entitybuilder.build();
And we can trivially do that in parallel (probably) so it wouldn't be too slow.
The tedium required to write out entity files for hundreds, or even dozens, of entities wouldn't be fun, but I also plan on writing a GUI game editor for the next game, which should play nice with this. I'd just need to figure out some way to serialize/deserialize an entity -- which I assume is non-trivial.
Functions
make_camera | Initializes the camera in the level. |
make_crates | Makes all crates in the level. |
make_doors | Makes all the doors in the level |
make_exit | Makes the level exit. |
make_floors | Makes the floors entities. |
make_horizontal | Creates "Prince horizontival the first" |
make_interact | Creates "Grabaron the wise" |
make_keys | Makes all the keys in the level. |
make_locks | Makes all the locks in the current level. |
make_switches | Makes all the door switches in the level |
make_vertical | Creates "Duke vert the pure" |
make_walls | Creates all wall entities |