New tiles
This commit is contained in:
parent
86b9134156
commit
dea1b8599a
5 changed files with 144 additions and 38 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use bevy::feathers::{FeathersPlugins, containers::*, controls::*, dark_theme::create_dark_theme, display::*, palette, rounded_corners::RoundedCorners, theme::UiTheme};
|
||||
use bevy::feathers::{FeathersPlugins, containers::*, controls::*, dark_theme::create_dark_theme, display::*, theme::UiTheme};
|
||||
use bevy::ui_widgets::{Activate};
|
||||
use bevy::prelude::*;
|
||||
|
||||
|
|
@ -22,6 +22,9 @@ struct WaterLabel;
|
|||
#[derive(Component, Clone, Default)]
|
||||
struct SpeedLabel;
|
||||
|
||||
const MAX_FREQUENCY: u32 = 512;
|
||||
const MIN_FREQUENCY: u32 = 1;
|
||||
|
||||
fn count_water_amount(grid: Res<Grid>, text: Single<&mut Text, With<WaterLabel>>) {
|
||||
let mut sum: u32 = 0;
|
||||
for i in 0..grid.cell_amount() {
|
||||
|
|
@ -119,7 +122,7 @@ fn simulation_speed() -> impl Scene {
|
|||
}
|
||||
on(|_activate: On<Activate>, mut time: ResMut<Time<Fixed>>, mut label: Single<&mut Text, With<SpeedLabel>>|{
|
||||
let mut current_frequency = (1./time.timestep().as_secs_f64()) as u32;
|
||||
current_frequency = if current_frequency == 1 {1} else {current_frequency / 2};
|
||||
current_frequency = if current_frequency <= MIN_FREQUENCY {MIN_FREQUENCY} else {current_frequency / 2};
|
||||
time.set_timestep_hz(current_frequency as f64);
|
||||
label.0 = format!("{} hz", current_frequency);
|
||||
})
|
||||
|
|
@ -134,7 +137,7 @@ fn simulation_speed() -> impl Scene {
|
|||
}
|
||||
on(|_activate: On<Activate>, mut time: ResMut<Time<Fixed>>, mut label: Single<&mut Text, With<SpeedLabel>>|{
|
||||
let mut current_frequency = (1./time.timestep().as_secs_f64()) as u32;
|
||||
current_frequency = if current_frequency >= 128 {128} else {current_frequency * 2};
|
||||
current_frequency = if current_frequency >= MAX_FREQUENCY {MAX_FREQUENCY} else {current_frequency * 2};
|
||||
time.set_timestep_hz(current_frequency as f64);
|
||||
label.0 = format!("{} hz", current_frequency);
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue