Move ship parts into it's own submodule
This commit is contained in:
32
src/ship.rs
Normal file
32
src/ship.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_rapier2d::prelude::*;
|
||||
|
||||
use crate::{GameAssets, Position, Rotation, Velocity, Wrapping};
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Ship;
|
||||
|
||||
pub fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
|
||||
commands
|
||||
.spawn((
|
||||
Collider::ball(0.7),
|
||||
Sensor,
|
||||
ActiveEvents::COLLISION_EVENTS,
|
||||
ActiveCollisionTypes::STATIC_STATIC,
|
||||
Ship,
|
||||
Wrapping,
|
||||
Position(Vec2::default()),
|
||||
Velocity(Vec2::ZERO),
|
||||
Rotation(0.0),
|
||||
Mesh2d(game_assets.ship().0),
|
||||
MeshMaterial2d(game_assets.ship().1),
|
||||
Transform::default().with_scale(Vec3::new(20.0, 20.0, 20.0)),
|
||||
))
|
||||
.with_child((
|
||||
Mesh2d(game_assets.thruster_mesh()),
|
||||
MeshMaterial2d(game_assets.thruster_mat_inactive()),
|
||||
Transform::default()
|
||||
.with_scale(Vec3::splat(0.5))
|
||||
.with_translation(Vec3::new(-0.5, 0.0, -0.1)),
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user