From 3d677c985455c67a13cc96bb7b9c2156eea55ecb Mon Sep 17 00:00:00 2001 From: P Marques <13932504-psmbrs@users.noreply.gitlab.com> Date: Mon, 17 Feb 2025 23:13:55 -0300 Subject: [PATCH] kinema game initial rust implementation --- 52_Kinema/rust/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/52_Kinema/rust/src/main.rs b/52_Kinema/rust/src/main.rs index 3b6e0321..9ce5c29e 100644 --- a/52_Kinema/rust/src/main.rs +++ b/52_Kinema/rust/src/main.rs @@ -1,6 +1,3 @@ -use std::io::Write; -use rand::Rng; - /** KINEMA BY RICHARD PAV * https://github.com/coding-horror/basic-computer-games/blob/main/52_Kinema/kinema.bas * Direct conversion from BASIC to Rust by Pablo Marques (marquesrs). @@ -11,10 +8,20 @@ use rand::Rng; * instead of the real formulation, which could lead to incorrect results. I have solved * this issue, but kept the old lines. To compile the original version, just uncomment the * code with the OLD label and comment the lines with the NEW label. - * example: gravity is now 9.81 instead of 10 + * example: gravity is now 9.81 instead of 10; Inputs and outputs are now float not integers... + * + * FORMULATION + * A BALL IS THROWN UPWARDS AT 9,36 METERS PER SECOND. + * HOW HIGH WILL IT GO (IN METERS)? (9,36 ^2) / (2 * 9,81) = 4,465321101 + * HOW LONG UNTIL IT RETURNS (IN SECONDS)? 2*(9,36 / 9,81) = 1,908256881 + * WHAT WILL ITS VELOCITY BE AFTER 1,09 SECONDS? 9,36- 9,81 * 1,09 = −1,3329 + * * 17/02/25 */ +use std::io::Write; +use rand::Rng; + fn subroutine(a: f64, q: &mut i32) { std::io::stdout().flush().unwrap(); //500 INPUT G @@ -104,4 +111,4 @@ fn main() { //180 GOTO 100 } //999 END -} \ No newline at end of file +}