Skip to content

Instantly share code, notes, and snippets.

@RyushiAok
Created January 1, 2024 15:01
Show Gist options
  • Save RyushiAok/fafb111f7a532b29040ba2af38887b9b to your computer and use it in GitHub Desktop.
Save RyushiAok/fafb111f7a532b29040ba2af38887b9b to your computer and use it in GitHub Desktop.
🐲2024.fsx
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))
@RyushiAok
Copy link
Author

2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment