added reset camera and boat buttons
This commit is contained in:
parent
42843165fc
commit
e19c099eb8
2 changed files with 15 additions and 7 deletions
|
@ -70,16 +70,22 @@ fn main() {
|
|||
});
|
||||
if gamepad.is_pressed(Button::RightTrigger) {
|
||||
gamepad.axis_data(Axis::RightStickY).map(|axis| {
|
||||
analog_input(3, dbg!(axis.value()));
|
||||
analog_input(3, axis.value());
|
||||
});
|
||||
gamepad.axis_data(Axis::RightStickX).map(|axis| {
|
||||
analog_input(4, dbg!(axis.value()));
|
||||
analog_input(4, axis.value());
|
||||
});
|
||||
} else {
|
||||
gamepad.axis_data(Axis::RightStickY).map(|axis| {
|
||||
analog_input(0, dbg!(axis.value()));
|
||||
analog_input(0, axis.value());
|
||||
});
|
||||
}
|
||||
if gamepad.is_pressed(Button::West) {
|
||||
keyboard_input(191)
|
||||
}
|
||||
if gamepad.is_pressed(Button::North) {
|
||||
keyboard_input(82)
|
||||
}
|
||||
if gamepad.is_pressed(Button::DPadLeft) {
|
||||
keyboard_input(65)
|
||||
}
|
||||
|
@ -103,6 +109,8 @@ fn main() {
|
|||
Key::Down => keyboard_input(40),
|
||||
Key::Left => keyboard_input(37),
|
||||
Key::Right => keyboard_input(39),
|
||||
Key::R => keyboard_input(82),
|
||||
Key::Slash => keyboard_input(191),
|
||||
_ => (),
|
||||
});
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ use spin::Mutex;
|
|||
#[cfg(feature = "rayon")]
|
||||
use rayon::prelude::*;
|
||||
|
||||
use crate::noise::lerp;
|
||||
|
||||
mod sampler;
|
||||
mod noise;
|
||||
|
||||
|
@ -113,6 +111,8 @@ fn render_frame(buffer: &mut [u32; WIDTH*HEIGHT]) {
|
|||
40 => camera[1] += 10.0*camera[2], // down
|
||||
37 => camera[0] -= 10.0*camera[2], // left
|
||||
39 => camera[0] += 10.0*camera[2], // right
|
||||
191 => *camera = [0.0, 0.0, 0.18], // reset camera (/)
|
||||
82 => boat.set_pos(Vector2::zeros()), // reset boat (r)
|
||||
61 => camera[2] *= 0.9, // +
|
||||
173 => camera[2] *= 1.1, // -
|
||||
65 => boat.theta -= 10.0, // A
|
||||
|
@ -146,9 +146,9 @@ fn render_frame(buffer: &mut [u32; WIDTH*HEIGHT]) {
|
|||
const HALF: Vector2<f32> = Vector2::new(WIDTH as f32 / 2.0, HEIGHT as f32 / 2.0);
|
||||
|
||||
#[cfg(feature = "rayon")]
|
||||
let mut buffer_iter = buffer.par_iter_mut();
|
||||
let buffer_iter = buffer.par_iter_mut();
|
||||
#[cfg(not(feature = "rayon"))]
|
||||
let mut buffer_iter = buffer.iter_mut();
|
||||
let buffer_iter = buffer.iter_mut();
|
||||
|
||||
buffer_iter.enumerate().for_each(|pix| {
|
||||
let y = pix.0 / WIDTH;
|
||||
|
|
Loading…
Reference in a new issue