1
Fork 0

implemented sail raising/lowering

This commit is contained in:
Andy Killorin 2023-09-16 20:37:40 -05:00
parent 4e95e2efca
commit 8d5c58ea7a
Signed by: ank
GPG key ID: B6241CA3B552BCA4
2 changed files with 15 additions and 0 deletions

View file

@ -78,6 +78,17 @@ fn main() {
gamepad.axis_data(Axis::LeftStickX).map(|axis| { gamepad.axis_data(Axis::LeftStickX).map(|axis| {
analog_input(1, axis.value()); analog_input(1, axis.value());
}); });
if gamepad.is_pressed(Button::LeftTrigger) {
gamepad.axis_data(Axis::LeftStickY).map(|axis| {
analog_input(5, axis.value());
});
}
if gamepad.is_pressed(Button::South) {
keyboard_input(69)
}
if gamepad.is_pressed(Button::East) {
keyboard_input(81)
}
if gamepad.is_pressed(Button::RightTrigger) { if gamepad.is_pressed(Button::RightTrigger) {
gamepad.axis_data(Axis::RightStickY).map(|axis| { gamepad.axis_data(Axis::RightStickY).map(|axis| {
analog_input(3, axis.value()); analog_input(3, axis.value());

View file

@ -136,9 +136,13 @@ fn render_frame(buffer: &mut [u32; WIDTH*HEIGHT]) {
1 => boat.theta += gain * (key[1] as f32 - 127.0) * 0.062, // analog rudder 1 => boat.theta += gain * (key[1] as f32 - 127.0) * 0.062, // analog rudder
3 => camera[1] -= gain * (key[1] as f32 - 127.0) * 0.1 * camera[2], // pan[y] 3 => camera[1] -= gain * (key[1] as f32 - 127.0) * 0.1 * camera[2], // pan[y]
4 => camera[0] += gain * (key[1] as f32 - 127.0) * 0.1 * camera[2], // pan[x] 4 => camera[0] += gain * (key[1] as f32 - 127.0) * 0.1 * camera[2], // pan[x]
5 => boat.sail += gain * (key[1] as f32 - 127.0) * 0.0013, // sail
69 => boat.sail += gain * 0.062, // E
81 => boat.sail -= gain * 0.062, // Q
_ => {} _ => {}
} }
} }
boat.sail = boat.sail.clamp(0.0, 1.5);
let wind = 0.0/RAD_TO_DEG; let wind = 0.0/RAD_TO_DEG;