Created
January 1, 2024 15:01
-
-
Save RyushiAok/fafb111f7a532b29040ba2af38887b9b to your computer and use it in GitHub Desktop.
π²2024.fsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.Threading | |
type Frame = string[] | |
type Animation = seq<Frame> | |
let mergeFrame (a: Frame) (b: Frame) : Frame = | |
Array.zip a b | |
|> Array.map (fun (a, b) -> | |
(a.ToCharArray(), b.ToCharArray()) | |
||> Array.zip | |
|> Array.map (fun (a, b) -> if b = ' ' then a else b) | |
|> String) | |
let mergeAnimation (a: Animation) (b: Animation) : Animation = | |
Seq.zip a b |> Seq.map (fun (a, b) -> mergeFrame a b) | |
let shiftFrame (lag: int) (frame: Frame) : Frame = | |
frame | |
|> Array.map (fun line -> | |
line.ToCharArray() | |
|> Array.permute (fun i -> (i + lag) % line.Length) | |
|> String) | |
let bgAnimation = | |
let bg = [| | |
" " | |
" " | |
" " | |
" " | |
" " | |
" " | |
"~~ ~~ ~~ " | |
" ~~~~ ~~~ ~~ " | |
"β ββ βββ ββ ββ" | |
"β βββββ βββββ ββββ β β ββ " | |
|] | |
seq { | |
let mutable i = 0 | |
while true do | |
yield shiftFrame i bg | |
i <- i + 1 | |
} | |
let dragonAnimation = | |
[ | |
[| | |
@" " | |
@" ζ¬εΉ΄γ " | |
@" γγγγγι‘γγγγγΎγ π " | |
@" /\/\__ _ _ _ " | |
@" ()()_ \ / \ / \ / \ /\ " | |
@" /oo/ \ \__/ _ \__/ _ \__/ _ \__/ / " | |
@" \_/ \_____/ \____/ \____/ \____/ " | |
@" " | |
@" " | |
@" " | |
|] | |
[| | |
@" " | |
@" ζ¬εΉ΄γ " | |
@" γγγγγι‘γγγγγΎγ π " | |
@" /\/\__ _ _ _ " | |
@" ()()_ \ / \ / \ / \ ____ " | |
@" /oo/ \ \__/ _ \__/ _ \__/ _ \__/ _/ " | |
@" \_/ \_____/ \____/ \____/ \____/ " | |
@" " | |
@" " | |
@" " | |
|] | |
] | |
|> List.replicate 1000 | |
|> List.concat | |
mergeAnimation bgAnimation dragonAnimation | |
|> Seq.iter (fun frame -> | |
Console.Clear() | |
frame |> Array.iter (printfn "%s") | |
Thread.Sleep(100)) |
Author
RyushiAok
commented
Jan 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment