Optimized code style (with comments, why that way is better )
#this function converts a value to pixels to create billy
function write-billy{
#these are the pixels(spaces) that make up the ascii image
$billy = ('sb8','nl9','sb6','sl4','sw5','nl4','sb5','sl3','sw9',
'nl3', 'sb4','sl3','sw11','nl3','sb3','sl3','sw3','sr3','sw1',
'sr3','sw3','nl3','sb3','sl3','sw2','sl1','sr1','sl1','sr1','sw1',
'sr1','sl1','sr1','sl1','sw2','nl4','sb2','sl3','sw4','sr3','sw1',
'sr3','sw4','nl3','sb2','sl3','sw1','sr1','sw1','sr1','sw7','sr1',
'sw1','sr1','sw1','nl3','sb1','sl5','sw1','sr1','sw9','sr1','sw1',
'nl5','sb1','sl7','sw1','sr7','sw1','nl7','sb2','sl6','sw2','sl1',
'sw3','sl1','sw2','nl6','sb3','sl4','sr2','sw1','sl1','sw3','sl1',
'sw1','sr2','nl4','sb7','sl1','sr9','nl1','sb5','sl2','sr2','sl2',
'sw3','sl2','sr2','nl2','sb3','sl9','nl9','sb2','nl21','sb1','nl23')
foreach ($i in $billy){
#this part determines how many spaces to print
# if you need string from some character to end
# you can use another substring() overload
$manychars = $i.substring(2)
#this next part determines the color to print
# switch statement in this case more intuitive and readable
# you can user [] indexer if you need string characters one by one
switch ($i[1]) {
'r' { $color = 'red' }
'l' { $color = 'black' }
'w' { $color = 'white' }
default { $color = $host.UI.RawUI.BackgroundColor } # default console color
}
#this part determines if it needs a -nonewline added
$newline = ($i[0] -eq 's') # already boolean(true/false) type
# right variable usage in this case ( Invoke-Expression > $null )
Write-Host (' '*$manychars) -BackgroundColor $color -NoNewLine:$newline
}
}
function write-slow ($text, $delay){
# Do not need string splitting, you can use string as char array
foreach ($i in $text.ToCharArray()){
# do not need any intermediate variables
Write-Host -NoNewline $i
Start-Sleep -Milliseconds $delay
}
Write-Host
}
write-billy
Write-Host
write-slow 'Would you like to play a game?' 125
Write-Host
write-slow 'press enter to fulfill your destiny' 125
Read-Host