Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhu committed Nov 11, 2024
1 parent 2a88378 commit d6cc57c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# 关卡设计
关卡主要分为:1.剧情类关卡;2.遗迹探索类关卡;3.无限深渊关卡。

# 已实现功能
# 已实现列表
- [x] 使用`cargo generate thebevyflock/bevy_new_2d`生成的2d游戏模板作为[游戏基础开发框架](https://github.com/TheBevyFlock/bevy_new_2d)
- [x][ASCII Space Shooter](https://github.com/JamesHDuffield/ascii-rust)开源项目Copy核心逻辑代码,并优化结构;

Expand Down
8 changes: 4 additions & 4 deletions src/gameplay/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn generate_object_geometry(sides: i32, min_radius: f32, max_radius: f32) ->
fn spawn_space_object(commands: &mut Commands) {
let mut rng = thread_rng();
let position = util::Math::random_2d_unit_vector() * 500.0;
let size: f32 = rng.gen_range(20.0..40.0);
let size: f32 = rng.gen_range(20.0..50.0);
commands.spawn((
SpaceObject,
Collider { radius: size },
Expand All @@ -45,7 +45,7 @@ fn spawn_space_object(commands: &mut Commands) {
Rotator {
speed: rng.gen_range(-0.4..0.4),
},
Health::new(50, 0),
Health::new(size as i32, 0),
Stroke::new(Colour::WHITE, 2.0),
ShapeBundle {
path: generate_object_geometry(10, size - 10., size + 10.),
Expand All @@ -55,8 +55,8 @@ fn spawn_space_object(commands: &mut Commands) {
..default()
},
ExplodesOnDespawn {
size_min: 50.0,
size_max: 100.0,
size_min: size,
size_max: size + 20.0,
..Default::default()
},
));
Expand Down
36 changes: 20 additions & 16 deletions src/gameplay/player.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
use crate::components::common::Health;
use crate::gameplay::gamelogic::{
game_not_paused, Allegiance, PlayerLevel, Targettable,
WillTarget,
use crate::{
components::common::Health,
gameplay::{
gamelogic::{game_not_paused, Allegiance, PlayerLevel, Targettable, WillTarget},
loot::{Cargo, Magnet},
physics::{BaseGlyphRotation, Collider, Physics},
GameState,
},
screens::AppState,
ship::{
engine::Engine,
platform::{Fonts, ShipBundle},
},
util::{Colour, RenderLayer},
AppSet, CameraShake, MainCamera,
};
use bevy::{
app::App,
ecs::{system::RunSystemOnce, world::Command},
prelude::*,
};
use crate::gameplay::loot::{Cargo, Magnet};
use crate::gameplay::physics::{BaseGlyphRotation, Collider, Physics};
use crate::gameplay::GameState;
use crate::screens::AppState;
use crate::ship::engine::Engine;
use crate::ship::platform::{Fonts, ShipBundle};
use crate::util::{Colour, RenderLayer};
use crate::{AppSet, CameraShake, MainCamera};
use bevy::app::App;
use bevy::ecs::system::RunSystemOnce;
use bevy::ecs::world::Command;
use bevy::prelude::*;
use std::f32::consts::PI;

pub(super) fn plugin(app: &mut App) {
Expand Down
4 changes: 2 additions & 2 deletions src/ship/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ fn orbit(current: Vec2, target: Vec2, distance: f32) -> Vec2 {
keep_at_distance(current, target, distance)
} else {
// Circle around
let tangental = Quat::from_rotation_z(PI / 2.0).mul_vec3(towards_target.extend(0.0));
let new_target = current + tangental.truncate();
let tangential = Quat::from_rotation_z(PI / 2.0).mul_vec3(towards_target.extend(0.0));
let new_target = current + tangential.truncate();
approach(current, new_target)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ship/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub mod turret;
use bevy::prelude::*;

pub(super) fn plugin(app: &mut App) {

app.add_plugins((
platform::plugin,
engine::plugin,
Expand Down
4 changes: 2 additions & 2 deletions src/util/colour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ impl Colour {
pub const SHIELD: Color = Color::srgb(120.0 / 255.0, 149.0 / 255.0, 171.0 / 255.0);
pub const INACTIVE: Color = Color::srgb(119.0 / 255.0, 117.0 / 255.0, 103.0 / 255.0);
pub const ENEMY: Color = Color::srgb(172.0 / 255.0, 138.0 / 255.0, 113.0 / 255.0);
pub const RED: Color = Color::srgb(255.0 / 255.0, 138.0 / 255.0, 113.0 / 255.0);
pub const RED: Color = Color::srgb(1.0, 138.0 / 255.0, 113.0 / 255.0);
pub const GREEN: Color = Color::srgb(130.0 / 255.0, 170.0 / 255.0, 119.0 / 255.0);
pub const YELLOW: Color = Color::srgb(237.0 / 255.0, 225.0 / 255.0, 158.0 / 255.0);
pub const PURPLE: Color = Color::srgb(138.0 / 255.0, 112.0 / 255.0, 225.0 / 255.0);
pub const PINK: Color = Color::srgb(255.0 / 255.0, 113.0 / 255.0, 159.0 / 255.0);
pub const PINK: Color = Color::srgb(1.0, 113.0 / 255.0, 159.0 / 255.0);
}
2 changes: 1 addition & 1 deletion src/util/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ impl RenderLayer {
panic!("Layer offset can not be 100 or more");
}
let base = self as u16 as f32;
return (base + offset) as f32;
base + offset
}

pub const fn as_z(self) -> f32 {
Expand Down

0 comments on commit d6cc57c

Please sign in to comment.