rendering a spherical player!!
This commit is contained in:
parent
5b8bd5c525
commit
e65f8b26ca
4 changed files with 31 additions and 4 deletions
|
@ -3,10 +3,12 @@ use bevy_rapier2d::prelude::*;
|
||||||
use player::player_plugin;
|
use player::player_plugin;
|
||||||
use scene::scene_plugin;
|
use scene::scene_plugin;
|
||||||
|
|
||||||
|
use crate::AppState;
|
||||||
|
|
||||||
mod player;
|
mod player;
|
||||||
mod scene;
|
mod scene;
|
||||||
mod set;
|
mod set;
|
||||||
|
|
||||||
fn game_plugin(app: &mut App) {
|
pub fn game_plugin(app: &mut App) {
|
||||||
app.add_plugins((player_plugin, scene_plugin));
|
app.add_plugins((player_plugin, scene_plugin));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use bevy::prelude::*;
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
||||||
|
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
|
||||||
|
@ -12,9 +12,23 @@ pub(super) fn player_plugin(app: &mut App) {
|
||||||
app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet));
|
app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_player(mut commands: Commands) {
|
pub fn add_player(
|
||||||
|
mut commands: Commands,
|
||||||
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
|
) {
|
||||||
|
// TODO replace
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn(Player {})
|
.spawn((
|
||||||
|
Player {},
|
||||||
|
MaterialMesh2dBundle {
|
||||||
|
mesh: meshes.add(Circle::new(20.)).into(),
|
||||||
|
material: materials.add(Color::linear_rgb(0., 1., 0.)),
|
||||||
|
transform: Transform::from_xyz(100., 100., 0.),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
))
|
||||||
.insert((
|
.insert((
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
Collider::cuboid(0.4 * METER, 0.9 * METER),
|
Collider::cuboid(0.4 * METER, 0.9 * METER),
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
|
||||||
|
use crate::AppState;
|
||||||
|
|
||||||
pub(super) fn scene_plugin(app: &mut App) {
|
pub(super) fn scene_plugin(app: &mut App) {
|
||||||
// app.add_systems(, )
|
// app.add_systems(, )
|
||||||
|
app.add_systems(Startup, setup_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn setup_view(mut commands: Commands) {
|
||||||
|
commands.spawn(Camera2dBundle::default());
|
||||||
|
println!("view setup");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_rapier2d::prelude::*;
|
use bevy_rapier2d::prelude::*;
|
||||||
|
use game::game_plugin;
|
||||||
|
|
||||||
mod game;
|
mod game;
|
||||||
|
|
||||||
|
@ -25,7 +26,9 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(METER))
|
.add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(METER))
|
||||||
|
.add_plugins(game_plugin)
|
||||||
.init_state::<AppState>()
|
.init_state::<AppState>()
|
||||||
.init_state::<PausedState>()
|
.init_state::<PausedState>()
|
||||||
|
.insert_state(AppState::InGame) // TODO dont
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue