Skip to content

Commit

Permalink
feat: touch input 🖐🏼️
Browse files Browse the repository at this point in the history
  • Loading branch information
eerii committed Dec 14, 2023
1 parent 2716595 commit 3663e70
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 159 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ dist
graphs
.vscode
.data
.envrc
capture*
*.tracy
163 changes: 162 additions & 1 deletion Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hello-bevy" # [CHANGE]: Set your project name.
version = "0.12.4"
version = "0.12.5"
edition = "2021"
description = "a bevy game template"
exclude = ["assets", "wasm", ".data"]
Expand All @@ -14,8 +14,11 @@ opt-level = 1

[features]
dev = [
"bevy/file_watcher", # Enables hot reloading of assets
"bevy/dynamic_linking", # Enables dynamic linking for faster compilation
]
save_schedule = []
mock_touch = []

[dependencies]
# The bevy engine <3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ this project is configured to use dynamic linking and fast recompiling by defaul
in order to have the fastest compile, you may install [mold](https://github.com/rui314/mold) and use rust nightly (`rustup default nightly`).
if you don't want some of these features, go to [.cargo/config](.cargo/config) and follow the instructions, or remove it to disable optimizations all together.

to run a debug build use the provided script:
to run a debug build use cargo or the provided script:

```sh
./run [args...] # This calls cargo run with some extra options
Expand Down
20 changes: 6 additions & 14 deletions examples/jump.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![allow(clippy::too_many_arguments)]

use std::cmp::Ordering;

use bevy::{
prelude::*,
sprite::MaterialMesh2dBundle,
Expand Down Expand Up @@ -143,7 +141,7 @@ fn update_sample(
}

// Jump
if keybinds.jump.iter().any(|bind| input.just_pressed(*bind)) {
if keybinds.jump.just_pressed(&input) {
player.velocity.y = JUMP_VEL;

let (mut text, mut counter) = counter.single_mut();
Expand All @@ -152,20 +150,14 @@ fn update_sample(
}

// Move
let vel = keybinds
.x_axis
.iter()
.map(|bind| movement.get(*bind))
.sum::<f32>()
.clamp(-1., 1.);

player.velocity.x = vel * MOVE_VEL;

/*if player.velocity.x.abs() > MOVE_CUTOFF {
let vel = keybinds.x_axis.get(&movement);
if vel.abs() > 0. {
player.velocity.x = vel * MOVE_VEL;
} else if player.velocity.x.abs() > MOVE_CUTOFF {
player.velocity.x *= MOVE_FACTOR;
} else {
player.velocity.x = 0.;
}*/
}

// Update position based on velocity and add bounds
*t += player.velocity.extend(0.) * time.delta_seconds();
Expand Down
7 changes: 2 additions & 5 deletions run
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/bin/sh
# Usage: ./run.sh [check] [release|trace|web] [args...]

# Hot reloading on debug builds
ARGS="--features bevy/file_watcher $@"

# Add asset path to env
export BEVY_ASSET_PATH=$PWD/assets
# Debug builds
ARGS="--features dev $@"

# Check build
if [ "$1" = "check" ]; then
Expand Down
4 changes: 1 addition & 3 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
use bevy::prelude::*;
use bevy_asset_loader::prelude::*;
use bevy_kira_audio::AudioSource;
use iyes_progress::{
prelude::*,
};
use iyes_progress::prelude::*;

use crate::GameState;

Expand Down
Loading

0 comments on commit 3663e70

Please sign in to comment.