rust port of 78_sine_wave

This commit is contained in:
AnthonyMichaelTDM
2022-03-10 19:39:09 -08:00
parent a13826a4b9
commit 6ef7fb86f4
3 changed files with 48 additions and 0 deletions

View File

@@ -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
");
}