rename camera to player

This commit is contained in:
Felix Ableitner 2020-12-29 17:01:28 +01:00
parent 374ea20d5b
commit b7eeb9ec9d
3 changed files with 11 additions and 11 deletions

View file

@ -1 +1 @@
pub mod camera;
pub mod player;

View file

@ -1,6 +1,6 @@
use bevy::prelude::*;
use rake::camera::FlyCamera;
use rake::camera::FlyCameraPlugin;
use rake::player::Player;
use rake::player::PlayerPlugin;
use std::process::exit;
fn main() {
@ -8,7 +8,7 @@ fn main() {
.add_resource(Msaa { samples: 4 })
.add_plugins(DefaultPlugins)
.add_startup_system(init.system())
.add_plugin(FlyCameraPlugin)
.add_plugin(PlayerPlugin)
.add_system(exit_game_system.system())
.run();
}
@ -24,7 +24,7 @@ fn init(
..Default::default()
})
.spawn(Camera3dBundle::default())
.with(FlyCamera::default());
.with(Player::default());
let box_mesh = meshes.add(Mesh::from(shape::Cube { size: 0.25 }));
let box_material = materials.add(Color::rgb(1.0, 0.2, 0.3).into());

View file

@ -1,6 +1,6 @@
use bevy::{input::mouse::MouseMotion, math::clamp, prelude::*};
pub struct FlyCamera {
pub struct Player {
/// The speed the FlyCamera moves at. Defaults to `1.0`
pub speed: f32,
/// The sensitivity of the FlyCamera's motion based on mouse movement. Defaults to `3.0`
@ -14,7 +14,7 @@ pub struct FlyCamera {
/// The current velocity of the FlyCamera. This value is always up-to-date, enforced by [FlyCameraPlugin](struct.FlyCameraPlugin.html)
pub velocity: Vec3,
}
impl Default for FlyCamera {
impl Default for Player {
fn default() -> Self {
Self {
speed: 1.5,
@ -62,7 +62,7 @@ fn movement_axis(
fn camera_movement_system(
time: Res<Time>,
keyboard_input: Res<Input<KeyCode>>,
mut query: Query<(&mut FlyCamera, &mut Transform)>,
mut query: Query<(&mut Player, &mut Transform)>,
) {
for (mut options, mut transform) in query.iter_mut() {
let (axis_h, axis_v, axis_float) = (movement_axis(&keyboard_input, KeyCode::D, KeyCode::A),
@ -115,7 +115,7 @@ fn mouse_motion_system(
time: Res<Time>,
mut state: ResMut<State>,
mouse_motion_events: Res<Events<MouseMotion>>,
mut query: Query<(&mut FlyCamera, &mut Transform)>,
mut query: Query<(&mut Player, &mut Transform)>,
) {
let mut delta: Vec2 = Vec2::zero();
for event in state.mouse_motion_event_reader.iter(&mouse_motion_events) {
@ -140,9 +140,9 @@ fn mouse_motion_system(
}
}
pub struct FlyCameraPlugin;
pub struct PlayerPlugin;
impl Plugin for FlyCameraPlugin {
impl Plugin for PlayerPlugin {
fn build(&self, app: &mut AppBuilder) {
app
.init_resource::<State>()