diff --git a/78_Sine_Wave/rust/Cargo.toml b/78_Sine_Wave/rust/Cargo.toml new file mode 100644 index 00000000..1ec69633 --- /dev/null +++ b/78_Sine_Wave/rust/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/78_Sine_Wave/rust/README.md b/78_Sine_Wave/rust/README.md new file mode 100644 index 00000000..7e85f9a1 --- /dev/null +++ b/78_Sine_Wave/rust/README.md @@ -0,0 +1,3 @@ +Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html) + +Conversion to [Rust](https://www.rust-lang.org/) by Anthony Rubick [AnthonyMichaelTDM](https://github.com/AnthonyMichaelTDM) diff --git a/78_Sine_Wave/rust/src/main.rs b/78_Sine_Wave/rust/src/main.rs new file mode 100644 index 00000000..f8a1cece --- /dev/null +++ b/78_Sine_Wave/rust/src/main.rs @@ -0,0 +1,37 @@ +fn main() { + let mut ticker:f64 = 0.0; + let mut spaces ; + + //pring welcome message + welcome(); + + //drawing loop + loop { + //print however many spaces + spaces = (26.0 + 25.0*ticker.sin()).round() as i32; + for _i in 0..=spaces{ + print!(" "); //print a space + } + + //print Creative or Computing + if (ticker.round() as i32) % 2 == 0 { + println!("CREATIVE"); + } else { + println!("COMPUTING"); + } + + //increment ticker + ticker += 0.25; + } + +} + +/** + * prints welcome message + */ +fn welcome() { + println!(" + SINE WAVE + CREATIVE COMPUTING MORRISTOWN, NEW JERSEY + "); +} \ No newline at end of file