rendering a spherical player!!

This commit is contained in:
TudbuT 2024-11-23 01:40:50 +01:00
parent 5b8bd5c525
commit e65f8b26ca
No known key found for this signature in database
GPG key ID: B3CF345217F202D3
4 changed files with 31 additions and 4 deletions

View file

@ -3,10 +3,12 @@ use bevy_rapier2d::prelude::*;
use player::player_plugin;
use scene::scene_plugin;
use crate::AppState;
mod player;
mod scene;
mod set;
fn game_plugin(app: &mut App) {
pub fn game_plugin(app: &mut App) {
app.add_plugins((player_plugin, scene_plugin));
}

View file

@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
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));
}
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
.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((
RigidBody::Dynamic,
Collider::cuboid(0.4 * METER, 0.9 * METER),

View file

@ -1,6 +1,14 @@
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use crate::AppState;
pub(super) fn scene_plugin(app: &mut App) {
// app.add_systems(, )
app.add_systems(Startup, setup_view);
}
pub(super) fn setup_view(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
println!("view setup");
}

View file

@ -1,6 +1,7 @@
#![allow(unused)]
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use game::game_plugin;
mod game;
@ -25,7 +26,9 @@ fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(METER))
.add_plugins(game_plugin)
.init_state::<AppState>()
.init_state::<PausedState>()
.insert_state(AppState::InGame) // TODO dont
.run();
}