generated from tipragot/rust
Add a camera system #69
|
@ -16,11 +16,11 @@ struct CameraSpeedScale(f32);
|
||||||
|
|
||||||
/// The minimum scale of the camera.
|
/// The minimum scale of the camera.
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct MinScale(f32);
|
struct MinimumScale(f32);
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
/// The maximum scale of the camera.
|
/// The maximum scale of the camera.
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct MaxScale(f32);
|
struct MaximumScale(f32);
|
||||||
|
|
||||||
/// Key settings for camera movement.
|
/// Key settings for camera movement.
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
|
@ -61,8 +61,8 @@ fn init_camera(mut commands: Commands) {
|
||||||
/// - [KeysMovementSettings]: The key settings for camera movement.
|
/// - [KeysMovementSettings]: The key settings for camera movement.
|
||||||
/// - [CameraSpeedMouvement]: The speed of camera movement.
|
/// - [CameraSpeedMouvement]: The speed of camera movement.
|
||||||
/// - [CameraSpeedScale]: The speed of camera scaling.
|
/// - [CameraSpeedScale]: The speed of camera scaling.
|
||||||
/// - [MinScale]: The minimum scale of the camera.
|
/// - [MinimumScale]: The minimum scale of the camera.
|
||||||
/// - [MaxScale]: The maximum scale of the camera.
|
/// - [MaximumScale]: The maximum scale of the camera.
|
||||||
fn init_resources(mut commands: Commands) {
|
fn init_resources(mut commands: Commands) {
|
||||||
commands.insert_resource(KeysMovementSettings {
|
commands.insert_resource(KeysMovementSettings {
|
||||||
up: KeyCode::Z,
|
up: KeyCode::Z,
|
||||||
|
@ -73,8 +73,8 @@ fn init_resources(mut commands: Commands) {
|
||||||
|
|
||||||
commands.insert_resource(CameraSpeedMouvement(10.0));
|
commands.insert_resource(CameraSpeedMouvement(10.0));
|
||||||
commands.insert_resource(CameraSpeedScale(0.1));
|
commands.insert_resource(CameraSpeedScale(0.1));
|
||||||
commands.insert_resource(MinScale(0.1));
|
commands.insert_resource(MinimumScale(0.1));
|
||||||
commands.insert_resource(MaxScale(10.0));
|
commands.insert_resource(MaximumScale(10.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Moves the camera with keyboard input.
|
/// Moves the camera with keyboard input.
|
||||||
|
@ -104,8 +104,8 @@ fn movement_system(
|
||||||
fn scale_system(
|
fn scale_system(
|
||||||
mut scroll_event: EventReader<MouseWheel>,
|
mut scroll_event: EventReader<MouseWheel>,
|
||||||
mut query: Query<&mut OrthographicProjection, With<Camera>>,
|
mut query: Query<&mut OrthographicProjection, With<Camera>>,
|
||||||
min_scale: Res<MinScale>,
|
min_scale: Res<MinimumScale>,
|
||||||
max_scale: Res<MaxScale>,
|
max_scale: Res<MaximumScale>,
|
||||||
scale_speed: Res<CameraSpeedScale>,
|
scale_speed: Res<CameraSpeedScale>,
|
||||||
) {
|
) {
|
||||||
for ev in scroll_event.read() {
|
for ev in scroll_event.read() {
|
||||||
|
|
Loading…
Reference in a new issue
No abreviations