mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-12 07:40:50 -08:00
kinema game initial rust implementation
This commit is contained in:
@@ -1,6 +1,3 @@
|
|||||||
use std::io::Write;
|
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
/** KINEMA BY RICHARD PAV
|
/** KINEMA BY RICHARD PAV
|
||||||
* https://github.com/coding-horror/basic-computer-games/blob/main/52_Kinema/kinema.bas
|
* https://github.com/coding-horror/basic-computer-games/blob/main/52_Kinema/kinema.bas
|
||||||
* Direct conversion from BASIC to Rust by Pablo Marques (marquesrs).
|
* 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
|
* 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
|
* 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.
|
* 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
|
* 17/02/25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use std::io::Write;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
fn subroutine(a: f64, q: &mut i32) {
|
fn subroutine(a: f64, q: &mut i32) {
|
||||||
std::io::stdout().flush().unwrap();
|
std::io::stdout().flush().unwrap();
|
||||||
//500 INPUT G
|
//500 INPUT G
|
||||||
@@ -104,4 +111,4 @@ fn main() {
|
|||||||
//180 GOTO 100
|
//180 GOTO 100
|
||||||
}
|
}
|
||||||
//999 END
|
//999 END
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user