Skip to content

Commit

Permalink
update transforms examples with changes from main
Browse files Browse the repository at this point in the history
* use derive component for used components
  • Loading branch information
l4desu-mizu committed Oct 31, 2021
1 parent 770e57a commit 7971574
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/transforms/global_vs_local_translation.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
use bevy::prelude::*;

// Define a marker for entities that should be changed via their global transform.
#[derive(Component)]
struct ChangeGlobal;

// Define a marker for entities that should be changed via their local transform.
#[derive(Component)]
struct ChangeLocal;

// Define a marker for entities that should move.
#[derive(Component)]
struct Move;

// Define a resource for the current movement direction;
#[derive(Default)]
#[derive(Default, Component)]
struct Direction(Vec3);

// Define component to decide when an entity should be ignored by the movement systems.
#[derive(Component)]
struct ToggledBy(KeyCode);

fn main() {
Expand Down
1 change: 1 addition & 0 deletions examples/transforms/rotation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::f32::consts::PI;
const FULL_TURN: f32 = 2.0 * PI;

// Define a component to designate a rotation speed to an entity.
#[derive(Component)]
struct Rotatable {
speed: f32,
}
Expand Down
1 change: 1 addition & 0 deletions examples/transforms/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bevy::prelude::*;
use std::f32::consts::PI;

// Define a component to keep information for the scaled object.
#[derive(Component)]
struct Scaling {
scale_direction: Vec3,
scale_speed: f32,
Expand Down
2 changes: 2 additions & 0 deletions examples/transforms/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bevy::prelude::*;
use std::f32::consts::PI;

// A struct for additional data of for a moving cube.
#[derive(Component)]
struct CubeState {
start_pos: Vec3,
move_speed: f32,
Expand All @@ -11,6 +12,7 @@ struct CubeState {

// A struct adding information to a scalable entity,
// that will be stationary at the center of the scene.
#[derive(Component)]
struct Center {
max_size: f32,
min_size: f32,
Expand Down
1 change: 1 addition & 0 deletions examples/transforms/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use bevy::prelude::*;

// Define a struct to keep some information about our entity.
// Here it's an arbitrary movement speed, the spawn location, and a maximum distance from it.
#[derive(Component)]
struct Movable {
spawn: Vec3,
max_distance: f32,
Expand Down

0 comments on commit 7971574

Please sign in to comment.