diff --git a/README.md b/README.md index 9927afa7264abb764c631e9eb47fec292c7e4c8f..0b4eb69fdc6cf5bdd056638234257b09430c301a 100644 --- a/README.md +++ b/README.md @@ -40,34 +40,36 @@ index in some theoretical sprite sheet. 1. Create one or more rules that define a pattern to match, a value to output, and optionally a percentage chance for that rule to be chosen. - * ```rust - use micro_autotile::AutoTileRule; - const GROUND: usize = 0; - const WALL: usize = 1; - - let alt_ground_rule = AutoTileRule::single_any_chance(GROUND, vec![123, 124, 125], 0.2); - let fallback_ground_rule = AutoTileRule::exact(GROUND, 126); + ```rust + use micro_autotile::AutoTileRule; + const GROUND: usize = 0; + const WALL: usize = 1; + + let alt_ground_rule = AutoTileRule::single_any_chance(GROUND, vec![123, 124, 125], 0.2); + let fallback_ground_rule = AutoTileRule::exact(GROUND, 126); ``` 2. (Optional) Put together your rules in a rule set. This can be skipped and the rule structs used directly - * ```rust - use micro_autotile::{AutoRuleSet, AutoTileRule}; - let ground_rules = AutoRuleSet::new(vec![alt_ground_rule, fallback_ground_rule]); - let wall_rules = AutoTileRule::exact(WALL, 35).into(); - let combined_rules = wall_rules + ground_rules; - ``` + ```rust + use micro_autotile::{AutoRuleSet, AutoTileRule}; + let ground_rules = AutoRuleSet::new(vec![alt_ground_rule, fallback_ground_rule]); + let wall_rules = AutoTileRule::exact(WALL, 35).into(); + let combined_rules = wall_rules + ground_rules; + ``` + 3. Elsewhere, generate a slice of level data wrapped in a `TileLayout` struct. This represents a single tile (the central element) and its surrounding neighbors. The order of the neighbors is important, and is laid out as though in a flattened grid. - * ```rust - use micro_autotile::TileLayout; - let layout = TileLayout::filled([ - GROUND, GROUND, GROUND, - GROUND, WALL, GROUND, - GROUND, GROUND, GROUND, - ]); + ```rust + use micro_autotile::TileLayout; + let layout = TileLayout::filled([ + GROUND, GROUND, GROUND, + GROUND, WALL, GROUND, + GROUND, GROUND, GROUND, + ]); ``` + 4. Produce an output using either the rule set or the rule directly (the same methods exist for both) - * ```rust - let output = combined_rules.resolve_match(&layout); - assert_eq!(output, Some(35)); + ```rust + let output = combined_rules.resolve_match(&layout); + assert_eq!(output, Some(35)); ``` \ No newline at end of file