Skip to content

Commit

Permalink
edit joystick 3
Browse files Browse the repository at this point in the history
  • Loading branch information
stutxo committed Sep 5, 2023
1 parent cc520d4 commit 9d23bd8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>☔ rain.run</title>
<script type="module">import init from './satrunner-4ea7aa8609da225.js';init('./satrunner-4ea7aa8609da225_bg.wasm');</script>
<script type="module">import init from './satrunner-8300bfae30d165ba.js';init('./satrunner-8300bfae30d165ba_bg.wasm');</script>


<style>
Expand All @@ -17,8 +17,8 @@
}
</style>

<link rel="preload" href="./satrunner-4ea7aa8609da225_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="./satrunner-4ea7aa8609da225.js"></head>
<link rel="preload" href="./satrunner-8300bfae30d165ba_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
<link rel="modulepreload" href="./satrunner-8300bfae30d165ba.js"></head>

<body>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1986,7 +1986,7 @@ async function __wbg_init(input) {
if (wasm !== undefined) return wasm;

if (typeof input === 'undefined') {
input = new URL('satrunner-4ea7aa8609da225_bg.wasm', import.meta.url);
input = new URL('satrunner-8300bfae30d165ba_bg.wasm', import.meta.url);
}
const imports = __wbg_get_imports();

Expand Down
Binary file not shown.
5 changes: 2 additions & 3 deletions src/game_core/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn update_joystick(
let mut current_direction = String::from("");
let angle = axis.y.atan2(axis.x);
let degree = angle * 180.0 / PI;
let tolerance = 20.0;
let tolerance = 30.0;

if degree >= -tolerance && degree <= tolerance {
current_direction = "Right".to_string();
Expand All @@ -120,7 +120,6 @@ pub fn update_joystick(

if player.last_direction.is_none()
|| player.last_direction.as_ref().unwrap() != &current_direction
&& !current_direction.is_empty()
{
should_send = true;
player.last_direction = Some(current_direction.clone());
Expand All @@ -132,7 +131,7 @@ pub fn update_joystick(
"Down" => player.target = Vec2::new(0.0, -1.0) * 1000.,
"Right" => player.target = Vec2::new(1.0, 0.0) * 1000.,
"Left" => player.target = Vec2::new(-1.0, 0.0) * 1000.,
_ => {}
_ => player.target = Vec2::new(0.0, 0.0),
};

let input = PlayerInput::new(
Expand Down

0 comments on commit 9d23bd8

Please sign in to comment.