From 850e6d978f288699f9cfa458d9302317e54b636e Mon Sep 17 00:00:00 2001 From: BeeverFeever Date: Sat, 11 Jun 2022 23:51:40 +1000 Subject: [PATCH] 78_sinewave ported to lua --- 78_Sine_Wave/lua/sinewave.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 78_Sine_Wave/lua/sinewave.lua diff --git a/78_Sine_Wave/lua/sinewave.lua b/78_Sine_Wave/lua/sinewave.lua new file mode 100644 index 00000000..0ea2630b --- /dev/null +++ b/78_Sine_Wave/lua/sinewave.lua @@ -0,0 +1,21 @@ +require("math") +require("string") + +print("\n Sine Wave") +print(" Creative Computing Morriston, New Jersy") +print("\n\n\n\n") + +-- Original BASIC version by David Ahl +-- Ported to lua by BeeverFeever(github), 2022 + +local toggleWord = true + +for t = 0, 40, 0.25 do + local gap = math.floor(26 + 25 * math.sin(t)) + if toggleWord == true then + -- string.rep used to add the gat at the front of the printed out words + print(string.rep(" ", math.floor(gap)) .. "Creative") + elseif toggleWord == false then + print(string.rep(" ", math.floor(gap)) .. "Computing") + end +end