Compare commits
3 commits
e6da44779e
...
d168e48759
| Author | SHA1 | Date | |
|---|---|---|---|
| d168e48759 | |||
| 9532911b00 | |||
| e34c82483a |
8 changed files with 47 additions and 18 deletions
|
|
@ -30,7 +30,8 @@ pub fn bubble_spawn_wave(commands: &mut Commands, asset_server: &Res<AssetServer
|
|||
for BubbleSplash { bubble_type, center, radius, nb_bubbles } in bubble_splashes {
|
||||
for _ in 0..*nb_bubbles {
|
||||
let angle = rng.random_range(0.0..TAU);
|
||||
let pos = center + Vec2::from_angle(angle) * radius;
|
||||
let spawn_radius = rng.random_range(0.0..1.0f32).sqrt() * radius;
|
||||
let pos = center + Vec2::from_angle(angle) * spawn_radius;
|
||||
|
||||
commands.spawn((
|
||||
Bubble { move_force: bubble_type.move_force },
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::core::game_state::{DispawnOnGameOver, GameStartupSet, GameState};
|
||||
use crate::core::game_state::DispawnOnGameOver;
|
||||
use crate::core::kirby::{Kirby, kirby_spawn};
|
||||
use crate::physics::sphere_collider::SphereCollider;
|
||||
use bevy::prelude::*;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pub enum GameState {
|
|||
#[default]
|
||||
Starting,
|
||||
Running,
|
||||
#[allow(dead_code)]
|
||||
Paused,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ pub fn bubble_receive_damage(
|
|||
pub fn kirby_receive_damage(
|
||||
mut bubble_exploded: ResMut<BubbleExplodedCountThisFrame>,
|
||||
mut kirby_hit: ResMut<KirbyHitCountThisFrame>,
|
||||
mut kirby_query: Query<(&Kirby, &GlobalTransform, &mut Life), (Without<Bubble>)>,
|
||||
mut kirby_query: Query<(&Kirby, &GlobalTransform, &mut Life), Without<Bubble>>,
|
||||
mut bubble_query: Query<
|
||||
(&GlobalTransform, &SphereCollider, &DamageDealer, &mut Life),
|
||||
(With<Bubble>, Without<Kirby>),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
use std::{thread::panicking, time::Duration};
|
||||
use std::time::Duration;
|
||||
|
||||
use bevy::{ecs::system::lifetimeless::SCommands, prelude::*};
|
||||
use rand::distr::slice::Empty;
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
core::{
|
||||
|
|
@ -11,7 +10,7 @@ use crate::{
|
|||
kirby::Kirby,
|
||||
life::Life,
|
||||
},
|
||||
map::map::{BOTTOM, LEFT, RIGHT, TOP},
|
||||
map::map::{BOTTOM, LEFT, RIGHT, RIGHT_DIR, TOP, UP_DIR},
|
||||
};
|
||||
|
||||
#[derive(Event)]
|
||||
|
|
@ -45,8 +44,8 @@ impl BubbleSplash {
|
|||
}
|
||||
}
|
||||
|
||||
const BASE_MOVE_FORCE: f32 = 3000.0;
|
||||
const BASE_LIFE: f32 = 10.0;
|
||||
const BASE_MOVE_FORCE: f32 = 6000.0;
|
||||
const BASE_LIFE: f32 = 20.0;
|
||||
|
||||
const NORMAL_BUBBLE: BubbleType = BubbleType {
|
||||
color: Color::linear_rgb(1.0, 1.0, 1.0),
|
||||
|
|
@ -61,7 +60,7 @@ const RED_BUBBLE: BubbleType = BubbleType {
|
|||
};
|
||||
|
||||
const GREEN_BUBBLE: BubbleType = BubbleType {
|
||||
color: Color::linear_rgb(1.0, 0.0, 0.0),
|
||||
color: Color::linear_rgb(0.0, 1.0, 0.0),
|
||||
move_force: BASE_MOVE_FORCE * 0.5,
|
||||
max_life: BASE_LIFE * 2.0,
|
||||
};
|
||||
|
|
@ -80,14 +79,24 @@ fn get_bubble_waves() -> BubbleWaves {
|
|||
vec![BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 10.0, 10), BubbleSplash::new(NORMAL_BUBBLE, TOP, 10.0, 10)],
|
||||
vec![BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 10.0, 100), BubbleSplash::new(NORMAL_BUBBLE, TOP, 10.0, 100)],
|
||||
vec![
|
||||
BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 10.0, 100),
|
||||
BubbleSplash::new(NORMAL_BUBBLE, TOP, 10.0, 100),
|
||||
BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 100.0, 100),
|
||||
BubbleSplash::new(NORMAL_BUBBLE, TOP, 100.0, 100),
|
||||
BubbleSplash::new(RED_BUBBLE, BOTTOM, 10.0, 20),
|
||||
],
|
||||
vec![
|
||||
BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 10.0, 200),
|
||||
BubbleSplash::new(RED_BUBBLE, RIGHT, 10.0, 100),
|
||||
BubbleSplash::new(RED_BUBBLE, LEFT, 10.0, 100),
|
||||
BubbleSplash::new(NORMAL_BUBBLE, RIGHT - UP_DIR * 20.0, 100.0, 200),
|
||||
BubbleSplash::new(RED_BUBBLE, RIGHT + UP_DIR * 20.0, 100.0, 100),
|
||||
BubbleSplash::new(RED_BUBBLE, LEFT, 100.0, 100),
|
||||
],
|
||||
vec![
|
||||
BubbleSplash::new(NORMAL_BUBBLE, RIGHT, 100.0, 200),
|
||||
BubbleSplash::new(RED_BUBBLE, RIGHT + UP_DIR * 40.0, 100.0, 100),
|
||||
BubbleSplash::new(GREEN_BUBBLE, RIGHT - UP_DIR * 40.0, 100.0, 100),
|
||||
],
|
||||
vec![BubbleSplash::new(GREEN_BUBBLE, Vec2::ZERO, 300.0, 1000)],
|
||||
vec![
|
||||
BubbleSplash::new(RED_BUBBLE, Vec2::ZERO, 300.0, 1000),
|
||||
BubbleSplash::new(GREEN_BUBBLE, Vec2::ZERO, 300.0, 1000),
|
||||
],
|
||||
],
|
||||
collectables: vec![
|
||||
|
|
@ -95,6 +104,21 @@ fn get_bubble_waves() -> BubbleWaves {
|
|||
vec![(CollectableType::NewKirby, LEFT)],
|
||||
vec![(CollectableType::SpeedBoost, BOTTOM)],
|
||||
vec![(CollectableType::ShieldBoost, BOTTOM)],
|
||||
vec![
|
||||
(CollectableType::ShieldBoost, TOP),
|
||||
(CollectableType::ShieldBoost, TOP + RIGHT_DIR * 40.0),
|
||||
(CollectableType::NewKirby, BOTTOM),
|
||||
],
|
||||
vec![(CollectableType::NewKirby, LEFT + UP_DIR * 40.0), (CollectableType::NewKirby, LEFT - UP_DIR * 40.0)],
|
||||
vec![
|
||||
(CollectableType::SpeedBoost, TOP),
|
||||
(CollectableType::SpeedBoost, BOTTOM),
|
||||
(CollectableType::SpeedBoost, TOP + RIGHT_DIR * 40.0),
|
||||
(CollectableType::SpeedBoost, BOTTOM + RIGHT_DIR * 40.0),
|
||||
(CollectableType::SpeedBoost, TOP - RIGHT_DIR * 40.0),
|
||||
(CollectableType::SpeedBoost, BOTTOM - RIGHT_DIR * 40.0),
|
||||
(CollectableType::NewKirby, RIGHT),
|
||||
],
|
||||
vec![],
|
||||
],
|
||||
current_wave: 0,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::core::{game_state::DispawnOnGameOver, wave::BubbleWaves};
|
||||
use crate::core::wave::BubbleWaves;
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ pub const LEFT: Vec2 = Vec2::new(-NEAR_LIMIT, 0.0);
|
|||
pub const TOP: Vec2 = Vec2::new(0.0, NEAR_LIMIT);
|
||||
pub const BOTTOM: Vec2 = Vec2::new(0.0, -NEAR_LIMIT);
|
||||
|
||||
pub const UP_DIR: Vec2 = Vec2::new(0.0, 1.0);
|
||||
pub const RIGHT_DIR: Vec2 = Vec2::new(1.0, 0.0);
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct MapBounds {
|
||||
pub min: Vec2,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const MAX_MAP_SIZE: usize = MAX_MAP_WIDTH * 2;
|
|||
const ARRAY_WIDTH: usize = MAX_MAP_SIZE / CELL_SIZE;
|
||||
const GRID_ARRAY_SIZE: usize = ARRAY_WIDTH * ARRAY_WIDTH;
|
||||
|
||||
const DENSITY_FORCE_SCALE: f32 = 6000.0;
|
||||
const DENSITY_FORCE_SCALE: f32 = 3000.0;
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct DensityGrid {
|
||||
|
|
@ -78,7 +78,7 @@ pub fn density_grid_force(
|
|||
let index = get_index_from_uvec2(neighbor_cell);
|
||||
let density = density_grid.grid[index];
|
||||
|
||||
density_gradient += offset.as_vec2() * density as f32;
|
||||
density_gradient += offset.as_vec2().normalize_or_zero() * density as f32;
|
||||
}
|
||||
}
|
||||
density_gradient += density_obj.random_offset; // To not have a "grid" thingy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue