Add difficulties
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex Page 2022-01-30 03:56:34 -05:00
parent 1628abea0e
commit 2be2b357ad
4 changed files with 64 additions and 22 deletions

45
src/difficulty.rs Normal file
View file

@ -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,
};

View file

@ -2,6 +2,7 @@
pub mod components; pub mod components;
pub mod constants; pub mod constants;
pub mod difficulty;
pub mod levels; pub mod levels;
pub mod resources; pub mod resources;
mod sidebar; mod sidebar;
@ -19,19 +20,19 @@ use std::time::Instant;
fn main() -> BError { fn main() -> BError {
let context = BTermBuilder::vga(80, 25) let context = BTermBuilder::vga(80, 25)
// .with_tile_dimensions(8, 16)
.with_fps_cap(60.0) .with_fps_cap(60.0)
.with_title("Kroz") .with_title("Kroz")
.build()?; .build()?;
let mut ss = SoundOutput::new(); let mut sound_system = SoundOutput::new();
let sound_effects = SoundEffects::new(&ss); let sound_effects = SoundEffects::new(&sound_system);
ss.play_sound(sound_effects.startup.clone()); sound_system.play_sound(sound_effects.startup.clone());
let mut ecs = World::new(); let mut ecs = World::new();
ecs.insert(ss); let starting_level = 0;
ecs.insert(LevelNumber(0)); ecs.insert(sound_system);
ecs.insert(LevelNumber(starting_level));
ecs.insert(ShowDebugInfo(false)); ecs.insert(ShowDebugInfo(false));
ecs.insert(Clock { ecs.insert(Clock {
last_ticked: Instant::now(), last_ticked: Instant::now(),
@ -39,12 +40,16 @@ fn main() -> BError {
ticks: 0, ticks: 0,
}); });
ecs.insert(sound_effects); ecs.insert(sound_effects);
let selected_difficulty = difficulty::SECRET;
ecs.insert(selected_difficulty);
ecs.insert(Stats { ecs.insert(Stats {
score: 1290, score: 0,
gems: 14, gems: selected_difficulty.starting_gems,
whips: 7, whips: selected_difficulty.starting_whips,
teleports: 0, whip_power: selected_difficulty.starting_whip_power,
keys: 0, teleports: selected_difficulty.starting_teleports,
keys: selected_difficulty.starting_keys,
}); });
ecs.register::<Position>(); ecs.register::<Position>();
@ -52,7 +57,7 @@ fn main() -> BError {
ecs.register::<Monster>(); ecs.register::<Monster>();
ecs.register::<Player>(); ecs.register::<Player>();
let map = Map::from_level(levels::get_level(0)); let map = Map::from_level(levels::get_level(starting_level));
map.spawn_entities(&mut ecs); map.spawn_entities(&mut ecs);
ecs.insert(map); ecs.insert(map);
@ -74,14 +79,5 @@ fn main() -> BError {
// let _ = gs.sound_system.play_sound(descent_effect); // 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)) main_loop(context, State::new(ecs))
} }

View file

@ -45,6 +45,7 @@ pub struct Stats {
pub score: u32, pub score: u32,
pub gems: u32, pub gems: u32,
pub whips: u32, pub whips: u32,
pub whip_power: u32,
pub teleports: u32, pub teleports: u32,
pub keys: u32, pub keys: u32,
} }

View file

@ -39,7 +39,7 @@ pub fn draw(ecs: &World, ctx: &mut BTerm) {
ctx.print_centered_at( ctx.print_centered_at(
SIDEBAR_POS_X + 6, SIDEBAR_POS_X + 6,
SIDEBAR_POS_Y + 4, SIDEBAR_POS_Y + 4,
ecs.read_resource::<LevelNumber>().0, ecs.read_resource::<LevelNumber>().0 + 1,
); );
ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 6, "Gems"); ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 6, "Gems");
ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 9, "Whips"); ctx.print(SIDEBAR_POS_X + 4, SIDEBAR_POS_Y + 9, "Whips");