Compare commits
No commits in common. 'c586c87afe9aa2378c57fdf5f8a44d2f0e25d69a' and 'ee95440d0466bbb267c13412296734e81d5c6e8d' have entirely different histories.
c586c87afe
...
ee95440d04
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,11 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "core"
|
|
||||||
description = "The Core Module For the Game"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
bevy = { workspace = true }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
use crate::movement::{MovementPlugin, Velocity};
|
|
||||||
|
|
||||||
pub struct CorePlugin;
|
|
||||||
|
|
||||||
impl Plugin for CorePlugin
|
|
||||||
{
|
|
||||||
fn build(&self, app: &mut App)
|
|
||||||
{
|
|
||||||
app.add_plugins(MovementPlugin)
|
|
||||||
.add_systems(Startup, setup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup(mut commands: Commands, server: Res<AssetServer>, mut ambient_light: ResMut<AmbientLight>)
|
|
||||||
{
|
|
||||||
ambient_light.brightness = 200.0;
|
|
||||||
|
|
||||||
// CAMERA
|
|
||||||
commands.spawn(Camera3dBundle {
|
|
||||||
transform: Transform::from_xyz(0.0, 0.0, -25.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
..default()
|
|
||||||
});
|
|
||||||
|
|
||||||
// LIGHT
|
|
||||||
commands.spawn(PointLightBundle {
|
|
||||||
point_light: PointLight {
|
|
||||||
intensity: 2_000_000.0,
|
|
||||||
range: 100.0,
|
|
||||||
radius: 10.0,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(0.0, 5.0, -5.0),
|
|
||||||
..default()
|
|
||||||
});
|
|
||||||
|
|
||||||
// BRICK
|
|
||||||
let brick_handle: Handle<Scene> = server.load("brick.glb#Scene0");
|
|
||||||
commands.spawn(SceneBundle {
|
|
||||||
scene: brick_handle,
|
|
||||||
transform: Transform::from_xyz(0.0, 8.0, 0.0),
|
|
||||||
.. default()
|
|
||||||
});
|
|
||||||
|
|
||||||
// BALL
|
|
||||||
let ball_handle: Handle<Scene> = server.load("ball.glb#Scene0");
|
|
||||||
commands.spawn((SceneBundle {
|
|
||||||
scene: ball_handle,
|
|
||||||
transform: Transform::from_xyz(0.0, -7.75, 0.0),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Velocity::new(0.5, 0.5, 0.0)));
|
|
||||||
|
|
||||||
// PADDLE
|
|
||||||
let paddle_handle: Handle<Scene> = server.load("paddle.glb#Scene0");
|
|
||||||
commands.spawn(SceneBundle {
|
|
||||||
scene: paddle_handle,
|
|
||||||
transform: Transform::from_xyz(0.0, -8.0, 0.0),
|
|
||||||
..default()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
pub mod core;
|
|
||||||
pub mod movement;
|
|
||||||
@ -1,39 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
pub struct MovementPlugin;
|
|
||||||
impl Plugin for MovementPlugin
|
|
||||||
{
|
|
||||||
fn build(&self, app: &mut App)
|
|
||||||
{
|
|
||||||
app.add_systems(Update, update_movement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Component)]
|
|
||||||
pub struct Velocity(Vec3);
|
|
||||||
|
|
||||||
impl Default for Velocity
|
|
||||||
{
|
|
||||||
fn default() -> Self
|
|
||||||
{
|
|
||||||
Self { 0: Vec3::new(0.0, 0.0, 0.0)}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Velocity
|
|
||||||
{
|
|
||||||
pub fn new(x: f32, y: f32, z: f32) -> Self{
|
|
||||||
Self { 0: Vec3::new(x, y, z) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SYSTEMS
|
|
||||||
fn update_movement(mut moving_objects: Query<(&Velocity, &mut Transform)>, time: Res<Time>)
|
|
||||||
{
|
|
||||||
for (velocity, mut transform) in moving_objects.iter_mut()
|
|
||||||
{
|
|
||||||
transform.translation += velocity.0 * time.delta_seconds();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
// use hello::hello::HelloPlugin;
|
// extern crate hello;
|
||||||
use core::core::CorePlugin;
|
use hello::hello::HelloPlugin;
|
||||||
|
|
||||||
fn main()
|
fn main()
|
||||||
{
|
{
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((DefaultPlugins, CorePlugin))
|
.add_plugins((DefaultPlugins, HelloPlugin))
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue