Updated aliases and added basic movement

main
Johannes Hendrik Gerard van der Weide 2023-11-22 15:08:16 +01:00
parent a5e6c99c47
commit e29be70a93
3 changed files with 54 additions and 2 deletions

BIN
assets/blobcat_hertog.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -75,7 +75,8 @@
pkgs.udev
pkgs.vulkan-loader
]}"
alias run="nixVulkanIntel cargo run"
alias runIntel="nixVulkanIntel cargo run"
alias runMommyIntel="nixVulkanIntel cargo mommy run"
onefetch
echo "Welcome to nix-hell uh nix-shell!"
'';

View File

@ -2,6 +2,57 @@ use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(
DefaultPlugins
.set(ImagePlugin::default_nearest())
.set(WindowPlugin {
primary_window: Some(Window {
title: "HertogGame".into(),
resolution: (500.0, 500.0).into(),
resizable: false,
..default()
}),
..default()
})
.build(),
)
.add_systems(Startup, setup)
.add_systems(Update, character_movement)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle::default());
let texture = asset_server.load("blobcat_hertog.png");
commands.spawn(SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(100.0, 100.0)),
..default()
},
texture,
..default()
});
}
fn character_movement(
mut characters: Query<(&mut Transform, &Sprite)>,
input: Res<Input<KeyCode>>,
time: Res<Time>,
) {
for (mut transform, _) in &mut characters {
if input.pressed(KeyCode::W) {
transform.translation.y += 100.0 * time.delta_seconds();
}
if input.pressed(KeyCode::S) {
transform.translation.y -= 100.0 * time.delta_seconds();
}
if input.pressed(KeyCode::D) {
transform.translation.x += 100.0 * time.delta_seconds();
}
if input.pressed(KeyCode::A) {
transform.translation.x -= 100.0 * time.delta_seconds();
}
}
}