Rewrite WorldSize as a newtype around Vec2
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m7s
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m7s
Closes #16 Bevy provides Deref and DerefMut derives, so that's nice. I'm not sure it makes any sense to keep the field private since those derefs expose the Vec2 anyway. I added an `impl Default` anyway, though.
This commit is contained in:
@@ -10,7 +10,7 @@ use bevy::{
|
||||
Vec2,
|
||||
primitives::{Circle, Triangle2d},
|
||||
},
|
||||
prelude::{Deref, Reflect, ReflectResource},
|
||||
prelude::{Deref, DerefMut, Reflect, ReflectResource},
|
||||
render::mesh::Mesh,
|
||||
sprite::ColorMaterial,
|
||||
};
|
||||
@@ -19,7 +19,7 @@ use bevy_inspector_egui::inspector_options::ReflectInspectorOptions;
|
||||
|
||||
use crate::{
|
||||
ASTEROID_SMALL_COLOR, BULLET_COLOR, PLAYER_SHIP_COLOR, SHIP_THRUSTER_COLOR_ACTIVE,
|
||||
SHIP_THRUSTER_COLOR_INACTIVE,
|
||||
SHIP_THRUSTER_COLOR_INACTIVE, config::WINDOW_SIZE,
|
||||
};
|
||||
|
||||
#[derive(Resource, Debug, Deref, Clone, Copy)]
|
||||
@@ -41,10 +41,13 @@ impl From<Lives> for String {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct WorldSize {
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
#[derive(Deref, DerefMut, Resource)]
|
||||
pub struct WorldSize(Vec2);
|
||||
|
||||
impl Default for WorldSize {
|
||||
fn default() -> Self {
|
||||
WorldSize(Vec2::new(WINDOW_SIZE.x, WINDOW_SIZE.y))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
|
||||
Reference in New Issue
Block a user