From d747cba9cd2ab5f542e334083d6987ed386d4cb7 Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Mon, 17 Apr 2023 15:26:07 +0100 Subject: [PATCH] Fix readme formatting --- README.md | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 9927afa..0b4eb69 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 -- GitLab