Browse Source

delint

master
Astro 7 months ago
parent
commit
5cbe06a0bc
  1. 4
      src/enemy.rs
  2. 1
      src/main.rs
  3. 14
      src/map.rs
  4. 2
      src/player.rs
  5. 7
      src/projectile.rs

4
src/enemy.rs

@ -59,12 +59,12 @@ pub fn walk(
// patrol
let x_bounds = enemy.bounds.0.clone();
let z_bounds = enemy.bounds.1.clone();
let (x, z) = enemy.patrol_target
let (x, z) = *enemy.patrol_target
// new patrol target
.get_or_insert_with(|| (
rng.gen_range(x_bounds),
rng.gen_range(z_bounds)
)).clone();
));
if Vec2::new(transform.translation.x - x,
transform.translation.z - z)
.length_squared() < 1.0

1
src/main.rs

@ -52,6 +52,7 @@ fn exit_on_escape(keyboard_input: Res<Input<KeyCode>>, mut exit: EventWriter<App
}
}
#[allow(unused)]
fn log_collisions(mut events: EventReader<CollisionEvent>) {
for event in events.iter() {
match event {

14
src/map.rs

@ -41,15 +41,9 @@ pub struct Bridge {
to: (i32, i32),
}
#[derive(Component)]
#[derive(Component, Default)]
pub struct GroundContact(pub usize);
impl std::default::Default for GroundContact {
fn default() -> Self {
GroundContact(0)
}
}
#[derive(Debug, Component)]
pub struct Ground {
/// (center x, width)
@ -269,9 +263,9 @@ fn add_island(
let transform = ground.to_transform();
let bounds = ground.to_box();
let mut soil_box = bounds.clone();
soil_box.max_y = soil_box.max_y - GRASS_HEIGHT;
let mut grass_box = bounds.clone();
let mut soil_box = bounds;
soil_box.max_y -= GRASS_HEIGHT;
let mut grass_box = bounds;
grass_box.min_y = soil_box.max_y;
let soil_mesh = meshes.add(Mesh::from(soil_box));

2
src/player.rs

@ -24,7 +24,7 @@ pub fn spawn_player(
asset_server: Res<AssetServer>,
) {
let input_source = match input.keys.iter().find(|(input_source, key)|
if [Key::Jump, Key::Shoot].iter().find(|k| k == &key).is_some() {
if [Key::Jump, Key::Shoot].iter().any(|k| k == key) {
! players.iter().any(|player| player.input_source == *input_source)
} else {
false

7
src/projectile.rs

@ -1,13 +1,8 @@
use std::collections::HashMap;
use rand::prelude::*;
use bevy::{
prelude::*,
};
use heron::prelude::*;
use crate::{
player::Player,
Layer,
};
use crate::Layer;
pub const EGG_RADIUS: f32 = 0.15;

Loading…
Cancel
Save