diff --git a/src/game.rs b/src/game.rs index bdd3b3a..2960436 100644 --- a/src/game.rs +++ b/src/game.rs @@ -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)); } diff --git a/src/game/player.rs b/src/game/player.rs index c586ea7..1e227d4 100644 --- a/src/game/player.rs +++ b/src/game/player.rs @@ -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>, + mut materials: ResMut>, +) { + // 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), diff --git a/src/game/scene.rs b/src/game/scene.rs index 6253aca..43975c7 100644 --- a/src/game/scene.rs +++ b/src/game/scene.rs @@ -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"); } diff --git a/src/main.rs b/src/main.rs index ffcea78..de1fa33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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::::pixels_per_meter(METER)) + .add_plugins(game_plugin) .init_state::() .init_state::() + .insert_state(AppState::InGame) // TODO dont .run(); }