commit e42586384a5fab0c00e4b89b3b4c2e70541b0261 Author: Elias Stepanik Date: Tue Oct 22 23:19:16 2024 +0200 Working diff --git a/assets/fonts/minecraft_font.ttf b/assets/fonts/minecraft_font.ttf new file mode 100644 index 0000000..61b4610 Binary files /dev/null and b/assets/fonts/minecraft_font.ttf differ diff --git a/src/components/player.rs b/src/components/player.rs new file mode 100644 index 0000000..3b68f38 --- /dev/null +++ b/src/components/player.rs @@ -0,0 +1,73 @@ +use bevy::input::ButtonInput; +use bevy::log::info; +use bevy::prelude::{Camera, Camera2dBundle, Commands, Component, GlobalTransform, KeyCode, Query, Res, Time, Transform, Vec3, With, Without}; +use bevy::utils::default; + +#[derive(Component)] +pub struct Player { + pub speed: f32, + pub position: Vec3, +} + +impl Player { + pub fn new(speed: f32, position: Vec3) -> Self { + Player { speed, position } + } +} + +pub fn setup(mut commands: Commands) { + // Setup camera + info!("Adding Camera"); + commands.spawn(Camera2dBundle { + transform: Transform { + scale: Vec3::splat(0.5), // Zoom in by reducing the scale (smaller scale means a larger view) + ..default() + }, + ..default() + }); + + + // Setup player with initial position + info!("Spawning player"); + commands.spawn(( + Player::new(500.0, Vec3::new(0.0, 0.0, 0.0)), // Initial player speed and position + Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)), + GlobalTransform::default(), + )); +} + +pub fn update_movement( + keyboard_input: Res>, + time: Res