Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
introduction to tic tac toe game
#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',
foreach ($i in $billy){
#this part determines how many spaces to print
if ($i.length -eq 3){
$manychars = $i.substring(2,1)}
else {
$manychars = $i.substring(2,2)}
#this next part determines the color to print
if ($i.substring(1,1) -eq 'b'){
$color = ""}
elseif ($i.substring(1,1) -eq 'l'){
$color = ' -backgroundcolor black'}
elseif ($i.substring(1,1) -eq 'w'){
$color = ' -backgroundcolor white'}
else {
$color = ' -backgroundcolor red'}
#this part determines if it needs a -nonewline added
if ($i.substring(0,1) -eq 's'){
$newline = " -nonewline"}
else {
$newline = " "}
Invoke-Expression "write-host (' '*$manychars) $color $newline"}
function write-slow ($text, $delay){
$textarray = $text.split(" ")
foreach ($i in $textarray){
$final = $i + " "
Write-Host -NoNewline $final
Start-Sleep -Milliseconds $delay}
write-slow 'Would you like to play a game?' 125
write-slow 'press enter to fulfill your destiny' 125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment