Crate updates
This commit is contained in:
parent
38d3333635
commit
9dcd94932f
8 changed files with 361 additions and 49 deletions
|
@ -16,12 +16,7 @@ use crate::{
|
|||
pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut Resources) {
|
||||
let mut to_kill: Vec<Entity> = Vec::new();
|
||||
|
||||
for (player_entity, (player, pos)) in &mut world.query::<(&mut Player, &mut Position)>() {
|
||||
// The player shouldn't be able to move while whipping
|
||||
if let Ok(_wants_to_whip) = world.get::<WantsToWhip>(player_entity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (player_entity, (player, pos)) in &mut world.query::<Without<(&mut Player, &mut Position), &WantsToWhip>>() {
|
||||
let now = Instant::now();
|
||||
if now - player.last_moved > Duration::from_secs_f32(PLAYER_STEP_PERIOD) {
|
||||
let destination = Point {
|
||||
|
@ -32,7 +27,7 @@ pub fn try_move(delta_x: i32, delta_y: i32, world: &mut World, resources: &mut R
|
|||
if resources.map.in_bounds(destination) {
|
||||
if try_step(destination, world, resources) {
|
||||
if let Some(monster_entity) = resources.map.get_tile_content_at(destination) {
|
||||
if let Ok(monster) = world.get::<Monster>(monster_entity) {
|
||||
if let Ok(monster) = world.get::<&Monster>(monster_entity) {
|
||||
resources.stats.add_score(damage_for_kind(monster.kind));
|
||||
resources.stats.take_gems(damage_for_kind(monster.kind));
|
||||
if let (Some(sound_effects), Some(sound_output)) =
|
||||
|
@ -276,7 +271,7 @@ fn try_step(point: Point, _world: &World, resources: &mut Resources) -> bool {
|
|||
pub fn whip(world: &mut World, resources: &mut Resources) {
|
||||
let mut to_add: Vec<Entity> = Vec::new();
|
||||
|
||||
for (entity, _) in world.query_mut::<With<Player, With<Position, Without<WantsToWhip, ()>>>>() {
|
||||
for (entity, _) in world.query_mut::<With<&Player, With<&Position, Without<&WantsToWhip, ()>>>>() {
|
||||
if resources.stats.whips > 0 {
|
||||
to_add.push(entity);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{array, iter, time::Duration};
|
||||
use std::{iter, time::Duration};
|
||||
|
||||
use bracket_lib::random::RandomNumberGenerator;
|
||||
|
||||
|
@ -92,7 +92,7 @@ impl SoundEffects {
|
|||
duration: Duration::from_millis(40),
|
||||
})
|
||||
.chain((0..4).flat_map(|_| {
|
||||
array::IntoIter::new([
|
||||
[
|
||||
Sound {
|
||||
sound_type: SoundType::Tone(100),
|
||||
duration: Duration::from_millis(15),
|
||||
|
@ -101,7 +101,7 @@ impl SoundEffects {
|
|||
sound_type: SoundType::Silence,
|
||||
duration: Duration::from_millis(15),
|
||||
},
|
||||
])
|
||||
]
|
||||
}))
|
||||
.collect(),
|
||||
}),
|
||||
|
|
|
@ -103,11 +103,12 @@ impl SoundOutput {
|
|||
}
|
||||
|
||||
pub fn play_sound(&mut self, samples: SoundSamples) -> SoundEffectHandle {
|
||||
let mut gain = oddio::Gain::new(
|
||||
oddio::FramesSignal::from(samples)
|
||||
);
|
||||
gain.set_gain(-10.0);
|
||||
self.mixer_handle
|
||||
.control::<oddio::Mixer<_>, _>()
|
||||
.play(oddio::MonoToStereo::new(oddio::Gain::new(
|
||||
oddio::FramesSignal::from(samples),
|
||||
0.50,
|
||||
)))
|
||||
.play(oddio::MonoToStereo::new(gain))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ pub fn run(world: &mut World, resources: &mut Resources) {
|
|||
};
|
||||
|
||||
if let Some(e) = resources.map.get_tile_content_at(destination) {
|
||||
if let Ok(_player) = world.get::<Player>(e) {
|
||||
if let Ok(_player) = world.get::<&Player>(e) {
|
||||
// TODO: Sound
|
||||
resources.map.clear_tile_content_at(Point::from(*position));
|
||||
resources.stats.take_gems(damage_for_kind(monster.kind));
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn run(world: &mut World, resources: &mut Resources) {
|
|||
|
||||
if let Some(dest) = destination {
|
||||
if let Some(e) = resources.map.get_tile_content_at(dest) {
|
||||
if let Ok(monster) = world.get::<Monster>(e) {
|
||||
if let Ok(monster) = world.get::<&Monster>(e) {
|
||||
resources.stats.add_score(damage_for_kind(monster.kind));
|
||||
to_kill.push(e);
|
||||
resources.map.clear_tile_content_at(dest);
|
||||
|
|
|
@ -2,7 +2,7 @@ use bracket_lib::prelude::*;
|
|||
|
||||
use crate::graphics::vga_color as vga;
|
||||
|
||||
#[derive(PartialEq, Copy, Clone)]
|
||||
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||
pub struct TileData {
|
||||
pub glyph: FontCharType,
|
||||
pub color_fg: (u8, u8, u8),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue