Skip to content

Commit 3d677c9

Browse files
author
P Marques
committed
kinema game initial rust implementation
1 parent ed068bd commit 3d677c9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

52_Kinema/rust/src/main.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use std::io::Write;
2-
use rand::Rng;
3-
41
/** KINEMA BY RICHARD PAV
52
* https://github.com/coding-horror/basic-computer-games/blob/main/52_Kinema/kinema.bas
63
* Direct conversion from BASIC to Rust by Pablo Marques (marquesrs).
@@ -11,10 +8,20 @@ use rand::Rng;
118
* instead of the real formulation, which could lead to incorrect results. I have solved
129
* this issue, but kept the old lines. To compile the original version, just uncomment the
1310
* code with the OLD label and comment the lines with the NEW label.
14-
* example: gravity is now 9.81 instead of 10
11+
* example: gravity is now 9.81 instead of 10; Inputs and outputs are now float not integers...
12+
*
13+
* FORMULATION
14+
* A BALL IS THROWN UPWARDS AT 9,36 METERS PER SECOND.
15+
* HOW HIGH WILL IT GO (IN METERS)? (9,36 ^2) / (2 * 9,81) = 4,465321101
16+
* HOW LONG UNTIL IT RETURNS (IN SECONDS)? 2*(9,36 / 9,81) = 1,908256881
17+
* WHAT WILL ITS VELOCITY BE AFTER 1,09 SECONDS? 9,36- 9,81 * 1,09 = −1,3329
18+
*
1519
* 17/02/25
1620
*/
1721

22+
use std::io::Write;
23+
use rand::Rng;
24+
1825
fn subroutine(a: f64, q: &mut i32) {
1926
std::io::stdout().flush().unwrap();
2027
//500 INPUT G
@@ -104,4 +111,4 @@ fn main() {
104111
//180 GOTO 100
105112
}
106113
//999 END
107-
}
114+
}

0 commit comments

Comments
 (0)