Skip to content

Commit

Permalink
Solved some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac8668 committed Feb 26, 2024
1 parent a2b9918 commit 8c9d3bc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
22 changes: 17 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ rotsprite = "0.1"

egui = "0.25"
bevy_egui = "0.25"
puffin = "0.19"
puffin_egui = "0.25"
puffin = "0.18"
puffin_egui = "0.26"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bevy_dylib = "0.13"
Expand Down
3 changes: 2 additions & 1 deletion src/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::render::render_resource::*;
use bevy::render::{render_asset::RenderAssetUsages, render_resource::*};
use std::collections::HashSet;

use crate::{prelude::*, rigidbody};
Expand Down Expand Up @@ -69,6 +69,7 @@ impl Chunk {
TextureDimension::D2,
vec![0; CHUNK_LENGHT.pow(2) * 4],
TextureFormat::Rgba8UnormSrgb,
RenderAssetUsages::RENDER_WORLD
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ fn render_actors(mut gizmos: Gizmos, actors: Query<&Actor>) {
}

fn _camera(keys: Res<ButtonInput<KeyCode>>, mut camera_q: Query<&mut Transform, With<Camera>>) {
let x = -(keys.pressed(KeyCode::A) as u8 as f32) + keys.pressed(KeyCode::D) as u8 as f32;
let y = -(keys.pressed(KeyCode::S) as u8 as f32) + keys.pressed(KeyCode::W) as u8 as f32;
let x = -(keys.pressed(KeyCode::KeyA) as u8 as f32) + keys.pressed(KeyCode::KeyD) as u8 as f32;
let y = -(keys.pressed(KeyCode::KeyS) as u8 as f32) + keys.pressed(KeyCode::KeyW) as u8 as f32;

let v = Vec2::new(x, y).normalize_or_zero().extend(0.);
camera_q.single_mut().translation += v * _CAMERA_SPEED;
Expand Down Expand Up @@ -221,7 +221,7 @@ pub fn grab_rigidbodies(
let (camera, camera_transform) = camera_q.single();
let window = window.single();

if input.pressed(KeyCode::R) {
if input.pressed(KeyCode::KeyR) {
if let Some(world_position) = window
.cursor_position()
.and_then(|cursor| camera.viewport_to_world(camera_transform, cursor))
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn main() {

let mut app = App::new();

app.add_state::<GameState>()
app.init_state::<GameState>()
.add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest()))
//local plugins
.add_plugins((
Expand Down
14 changes: 7 additions & 7 deletions src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub fn tool_system(
mut tool: Query<(&mut Transform, &GlobalTransform, &mut Sprite), With<Tool>>,
mut camera: Query<(&Camera, &GlobalTransform), Without<Tool>>,
tool_front_ent: Query<Entity, With<ToolFront>>,
querys: (Query<&Window>, Query<(&mut TextureAtlas, &Player)>),
querys: (Query<&Window>, Query<(&mut Sprite, &Player)>),
resources: (ResMut<ChunkManager>, ResMut<DirtyRects>, Res<Inputs>),
materials: (Res<Assets<Materials>>, Res<MaterialsHandle>),
) {
Expand Down Expand Up @@ -379,10 +379,10 @@ pub fn get_input(
}

//Movement
if keys.pressed(KeyCode::A) {
if keys.pressed(KeyCode::KeyA) {
inputs.left = 1.;
}
if keys.pressed(KeyCode::D) {
if keys.pressed(KeyCode::KeyD) {
inputs.right = 1.;
}

Expand All @@ -395,13 +395,13 @@ pub fn get_input(
}

//Numbers, to select atoms
if keys.just_pressed(KeyCode::Key1) {
if keys.just_pressed(KeyCode::Digit1) {
inputs.numbers[0] = true;
} else if keys.just_pressed(KeyCode::Key2) {
} else if keys.just_pressed(KeyCode::Digit2) {
inputs.numbers[1] = true;
} else if keys.just_pressed(KeyCode::Key3) {
} else if keys.just_pressed(KeyCode::Digit3) {
inputs.numbers[2] = true;
} else if keys.just_pressed(KeyCode::Key4) {
} else if keys.just_pressed(KeyCode::Digit4) {
inputs.numbers[3] = true;
}
}
Expand Down

0 comments on commit 8c9d3bc

Please sign in to comment.