kroz-rs/src/main.rs
Alex Page 784e205357
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Implement whipping
2022-01-30 17:06:27 -05:00

87 lines
2.4 KiB
Rust

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
pub mod components;
pub mod constants;
pub mod difficulty;
pub mod levels;
pub mod resources;
mod sidebar;
mod state;
pub mod systems;
pub mod tile_data;
pub mod vga_color;
use bracket_lib::prelude::*;
use components::{Monster, Player, Position, Renderable, WantsToWhip};
use resources::{
Clock, LevelNumber, Map, ShowDebugInfo, SoundEffects, SoundOutput, Stats, StopClock,
};
use specs::prelude::*;
use state::State;
use std::time::Instant;
fn main() -> BError {
let context = BTermBuilder::vga(80, 25)
.with_fps_cap(60.0)
.with_title("Kroz")
.build()?;
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();
let starting_level = 0;
ecs.insert(sound_system);
ecs.insert(LevelNumber(starting_level));
ecs.insert(ShowDebugInfo(false));
ecs.insert(StopClock(false));
ecs.insert(Clock {
last_ticked: Instant::now(),
has_ticked: false,
ticks: 0,
});
ecs.insert(sound_effects);
let selected_difficulty = difficulty::SECRET;
ecs.insert(selected_difficulty);
ecs.insert(Stats {
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::<Position>();
ecs.register::<Renderable>();
ecs.register::<Monster>();
ecs.register::<Player>();
ecs.register::<WantsToWhip>();
let map = Map::from_level(levels::get_level(starting_level));
map.spawn_entities(&mut ecs);
ecs.insert(map);
// let descent_sounds: Vec<Sound> = (20..100)
// .rev()
// .flat_map(|x| {
// (1..10).rev().flat_map(move |y| {
// vec![Sound {
// sound_type: SoundType::Tone(x * y * y),
// duration: Duration::from_millis((y as f64 / 1.5) as u64),
// }]
// })
// })
// .collect();
// let descent_effect = gs.sound_system.render_sound_effect(SoundEffect {
// sounds: descent_sounds,
// });
// let _ = gs.sound_system.play_sound(descent_effect);
main_loop(context, State::new(ecs))
}