Compare commits
No commits in common. "9f04ec861ed535d543bb3079df9ccb059431c42a" and "a859d72da33769e0ce1f57cdc045ffe595021ac7" have entirely different histories.
9f04ec861e
...
a859d72da3
4 changed files with 14 additions and 57 deletions
|
@ -17,9 +17,7 @@
|
|||
* (?) multiplayer
|
||||
* more audio
|
||||
* "jumpable" component to avoid jumping on sensors
|
||||
* bug: in level2, move the blue character to win, then reset. The characters are lighter than expected. (also level 4)
|
||||
* redshift warning
|
||||
* itchio test
|
||||
* bug: in level2, move the blue character to win, then reset. The characters are lighter than expected.
|
||||
|
||||
## Build
|
||||
|
||||
|
|
26
src/game.rs
26
src/game.rs
|
@ -52,8 +52,7 @@ impl Plugin for GamePlugin {
|
|||
.with_system(player_movement_system)
|
||||
.with_system(level_keyboard_system)
|
||||
.with_system(move_camera)
|
||||
.with_system(character_particle_effect_system)
|
||||
.with_system(move_win_text_system),
|
||||
.with_system(character_particle_effect_system),
|
||||
)
|
||||
.add_system_to_stage(CoreStage::PostUpdate, collision_event_system);
|
||||
}
|
||||
|
@ -102,9 +101,6 @@ pub struct CollisionCount(usize);
|
|||
#[derive(Component)]
|
||||
pub struct Melty(pub Color);
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct WinText;
|
||||
|
||||
// Systems
|
||||
|
||||
fn setup(
|
||||
|
@ -290,7 +286,8 @@ fn collision_event_system(
|
|||
.clamp(Vec4::ZERO, Vec4::ONE);
|
||||
|
||||
// If color approximately white
|
||||
if app_state.current() == &AppState::Game && new_color.min_element() >= 0.9
|
||||
if app_state.current() == &AppState::Game
|
||||
&& Vec4::from(new_color).min_element() >= 0.9
|
||||
{
|
||||
app_state.replace(AppState::Win).ok();
|
||||
}
|
||||
|
@ -494,8 +491,7 @@ fn win_setup(
|
|||
transform: Transform::from_xyz(0., 0., 3.),
|
||||
..default()
|
||||
})
|
||||
.insert(Level)
|
||||
.insert(WinText);
|
||||
.insert(Level);
|
||||
commands
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
|
@ -510,8 +506,7 @@ fn win_setup(
|
|||
transform: Transform::from_xyz(0., 0., 4.),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Level)
|
||||
.insert(WinText);
|
||||
.insert(Level);
|
||||
}
|
||||
|
||||
fn move_camera(
|
||||
|
@ -540,17 +535,6 @@ fn move_camera(
|
|||
}
|
||||
}
|
||||
|
||||
fn move_win_text_system(
|
||||
camera_query: Query<&Transform, With<Camera>>,
|
||||
mut win_text_query: Query<&mut Transform, (With<WinText>, Without<Camera>)>,
|
||||
) {
|
||||
let camera_pos = camera_query.single();
|
||||
for mut pos in win_text_query.iter_mut() {
|
||||
pos.translation.x = camera_pos.translation.x;
|
||||
pos.translation.y = camera_pos.translation.y;
|
||||
}
|
||||
}
|
||||
|
||||
fn level_keyboard_system(
|
||||
mut commands: Commands,
|
||||
mut current_level: ResMut<CurrentLevel>,
|
||||
|
|
16
src/menu.rs
16
src/menu.rs
|
@ -20,22 +20,6 @@ impl Plugin for MenuPlugin {
|
|||
|
||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
commands
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
"Note:\nAudio is NOT available in the WASM build.",
|
||||
TextStyle {
|
||||
font: font.clone(),
|
||||
font_size: 24.0,
|
||||
color: Color::rgba(1., 0.4, 0.4, 1.),
|
||||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
transform: Transform::from_xyz(0., -128.0, 0.),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Menu);
|
||||
commands
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bevy::{prelude::*, sprite::Mesh2dHandle};
|
||||
use rand::{rngs::ThreadRng, Rng};
|
||||
use rand::Rng;
|
||||
use rand_distr::{Distribution, UnitCircle};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
@ -68,20 +68,15 @@ pub struct ParticleComponent {
|
|||
}
|
||||
|
||||
impl ParticleComponent {
|
||||
pub fn new(rng: &mut ThreadRng) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let mut particle_component: Self = Self::default();
|
||||
particle_component.randomize_velocity(rng, MIN_VELOCITY, MAX_VELOCITY);
|
||||
particle_component.randomize_velocity(MIN_VELOCITY, MAX_VELOCITY);
|
||||
particle_component
|
||||
}
|
||||
|
||||
pub fn randomize_velocity(
|
||||
&mut self,
|
||||
rng: &mut ThreadRng,
|
||||
min_velocity: f32,
|
||||
max_velocity: f32,
|
||||
) {
|
||||
let random_direction: [f32; 2] = UnitCircle.sample(rng);
|
||||
let random_magnitude: f32 = rng.gen_range(min_velocity..max_velocity);
|
||||
pub fn randomize_velocity(&mut self, min_velocity: f32, max_velocity: f32) {
|
||||
let random_direction: [f32; 2] = UnitCircle.sample(&mut rand::thread_rng());
|
||||
let random_magnitude: f32 = rand::thread_rng().gen_range(min_velocity..max_velocity);
|
||||
self.velocity = Vec3::new(random_direction[0], random_direction[1], 0.0) * random_magnitude;
|
||||
}
|
||||
}
|
||||
|
@ -92,8 +87,6 @@ fn particle_effect_startup(
|
|||
particle_mesh: Res<ParticleMesh>,
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
) {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
for _p in 0..POOL_COUNT {
|
||||
let color_mesh = ColorMesh2dBundle {
|
||||
mesh: particle_mesh.square.clone(),
|
||||
|
@ -103,7 +96,7 @@ fn particle_effect_startup(
|
|||
|
||||
commands
|
||||
.spawn_bundle(color_mesh)
|
||||
.insert(ParticleComponent::new(&mut rng));
|
||||
.insert(ParticleComponent::new());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,8 +110,6 @@ fn particle_effect_system(
|
|||
mut particle_effect: ResMut<ParticleEffectResource>,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
let delta_seconds: f32 = f32::max(0.001, time.delta_seconds());
|
||||
let delta_position: Vec3 = particle_effect.translation - particle_effect.prev_translation;
|
||||
// let overall_velocity: Vec3 = delta_position / delta_seconds;
|
||||
|
@ -133,7 +124,7 @@ fn particle_effect_system(
|
|||
.distance_squared(particle_effect.translation);
|
||||
if squared_distance > particle_effect.radius_squared {
|
||||
transform.translation = particle_effect.translation;
|
||||
particle_component.randomize_velocity(&mut rng, MIN_VELOCITY, MAX_VELOCITY);
|
||||
particle_component.randomize_velocity(MIN_VELOCITY, MAX_VELOCITY);
|
||||
}
|
||||
|
||||
if let Some(material) = materials.get_mut(color_material) {
|
||||
|
|
Loading…
Reference in a new issue