diff --git a/src/difficulty.rs b/src/difficulty.rs new file mode 100644 index 0000000..87add56 --- /dev/null +++ b/src/difficulty.rs @@ -0,0 +1,45 @@ +#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)] +pub struct Difficulty { + pub value: u32, + pub starting_gems: u32, + pub starting_whips: u32, + pub starting_teleports: u32, + pub starting_keys: u32, + pub starting_whip_power: u32, +} + +pub const SECRET: Difficulty = Difficulty { + value: 9, + starting_gems: 250, + starting_whips: 100, + starting_teleports: 50, + starting_keys: 1, + starting_whip_power: 3, +}; + +pub const NOVICE: Difficulty = Difficulty { + value: 8, + starting_gems: 20, + starting_whips: 10, + starting_teleports: 0, + starting_keys: 0, + starting_whip_power: 0, +}; + +pub const EXPERIENCED: Difficulty = Difficulty { + value: 5, + starting_gems: 15, + starting_whips: 0, + starting_teleports: 0, + starting_keys: 0, + starting_whip_power: 0, +}; + +pub const ADVANCED: Difficulty = Difficulty { + value: 2, + starting_gems: 10, + starting_whips: 0, + starting_teleports: 0, + starting_keys: 0, + starting_whip_power: 0, +}; diff --git a/src/main.rs b/src/main.rs index af74b14..344cc9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ pub mod components; pub mod constants; +pub mod difficulty; pub mod levels; pub mod resources; mod sidebar; @@ -19,19 +20,19 @@ use std::time::Instant; fn main() -> BError { let context = BTermBuilder::vga(80, 25) - // .with_tile_dimensions(8, 16) .with_fps_cap(60.0) .with_title("Kroz") .build()?; - let mut ss = SoundOutput::new(); - let sound_effects = SoundEffects::new(&ss); - ss.play_sound(sound_effects.startup.clone()); + let mut sound_system = SoundOutput::new(); + let sound_effects = SoundEffects::new(&sound_system); + sound_system.play_sound(sound_effects.startup.clone()); let mut ecs = World::new(); - ecs.insert(ss); - ecs.insert(LevelNumber(0)); + let starting_level = 0; + ecs.insert(sound_system); + ecs.insert(LevelNumber(starting_level)); ecs.insert(ShowDebugInfo(false)); ecs.insert(Clock { last_ticked: Instant::now(), @@ -39,12 +40,16 @@ fn main() -> BError { ticks: 0, }); ecs.insert(sound_effects); + + let selected_difficulty = difficulty::SECRET; + ecs.insert(selected_difficulty); ecs.insert(Stats { - score: 1290, - gems: 14, - whips: 7, - teleports: 0, - keys: 0, + score: 0, + gems: selected_difficulty.starting_gems, + whips: selected_difficulty.starting_whips, + whip_power: selected_difficulty.starting_whip_power, + teleports: selected_difficulty.starting_teleports, + keys: selected_difficulty.starting_keys, }); ecs.register::(); @@ -52,7 +57,7 @@ fn main() -> BError { ecs.register::(); ecs.register::(); - let map = Map::from_level(levels::get_level(0)); + let map = Map::from_level(levels::get_level(starting_level)); map.spawn_entities(&mut ecs); ecs.insert(map); @@ -74,14 +79,5 @@ fn main() -> BError { // let _ = gs.sound_system.play_sound(descent_effect); - // let effect = gs.sound_system.render_sound_effect(SoundEffect { - // sounds: vec![Sound { - // sound_type: SoundType::Tone(3500), - // duration: Duration::from_millis(4000), - // }], - // }); - - // let _ = gs.sound_system.play_sound(effect); - main_loop(context, State::new(ecs)) } diff --git a/src/resources/mod.rs b/src/resources/mod.rs index 330b80e..1a39908 100644 --- a/src/resources/mod.rs +++ b/src/resources/mod.rs @@ -45,6 +45,7 @@ pub struct Stats { pub score: u32, pub gems: u32, pub whips: u32, + pub whip_power: u32, pub teleports: u32, pub keys: u32, } diff --git a/src/sidebar.rs b/src/sidebar.rs index 08f66b2..4e09acf 100644 --- a/src/sidebar.rs +++ b/src/sidebar.rs @@ -39,7 +39,7 @@ pub fn draw(ecs: &World, ctx: &mut BTerm) { ctx.print_centered_at( SIDEBAR_POS_X + 6, SIDEBAR_POS_Y + 4, - ecs.read_resource::().0, + ecs.read_resource::().0 + 1, ); ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 6, "Gems"); ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 9, "Whips");