Gwith

Text Game

May 8th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. Function Write-Char{ #this function grabs each character in a variable and writes it out to screen with a small delay, causing a very familiar Final Fantasy or Zelda affect.
  2. Param
  3. (
  4. #Specify the characters to write to screen
  5. [Parameter(Mandatory=$true)]
  6. [Alias("characters")]
  7. [string]$text,
  8.  
  9. #Specify the delay between characters
  10. [Parameter(Mandatory=$false)]
  11. [Alias("pause","wait")]
  12. [string]$delay='15'
  13. )
  14. $i=0
  15. Do {
  16. If ($i -eq $host.ui.RawUI.BufferSize.Width){ #this logic detects if the current character would force the window to scroll, and if so will write to a new line
  17. Write-Host ($text.Substring($i,1))
  18. }
  19. else{ #if the current character won't cause the window to scroll horizontally, then add the current character to the line
  20. Write-Host ($text.Substring($i,1)) -NoNewline
  21. }
  22.  
  23.  
  24. Start-Sleep -Milliseconds $delay #amount of time to wait between each character
  25. $i++ #increment $i to move to the next character
  26. }
  27. Until ($i -eq ($text.Length - 1))
  28.  
  29. }
  30.  
  31. $intro = "Welcome to ISIS `nYour death begins here`n
  32. From the beginning of time man has sought its own destruction, in this time of despair only one hero may rise amongst the ranks to deter evil from` taking
  33. its place in the world. Will you be this hero? Can you stand up for what is right? Can you protect the helpless from there own demise? You hero, our are only hope.`n"
  34.  
  35. Write-Char -characters $intro
  36.  
  37. function Menu
  38. {
  39. # Show the user the information you want them to act on -ie. the choice
  40. Write-Host "********************"
  41. Write-Host ""
  42. Write-Host "Select class:"
  43. Write-Host "1) Warrior"
  44. Write-Host "2) Mage"
  45. # Request the choice from the user
  46. $MenuChoice = Read-Host "Choice"
  47. # If the User doesn't choose 1 or 2, make them choose again:
  48. While ( $MenuChoice -ne "1" -and $MenuChoice -ne "2" )
  49. {
  50. Write-Host "Invalid selection. Please choose 1 or 2"
  51. $MenuChoice = Read-Host "Choice"
  52. }
  53. # Return the selection the user made based on $menuchoice
  54. switch ( $MenuChoice )
  55. {
  56. "1" { Write-Host ("You have selected the Warrior") }
  57. "2" { Write-Host ("You have selected the Mage") }
  58.  
  59. }
  60. }
  61.  
  62. Menu
  63.  
  64. function Warrior
  65. {
  66. Write-Host "Select A skill"
  67. Write-Host "1) For Mortal Strike"
  68. Write-Host "2) For Rage Strike"
  69. $skill = Read-Host "Skill"
  70. While ($skill -ne "1" -and $skill -ne "2" )
  71. {
  72. write-host "Invalid selection. Please choose 1 or 2"
  73. $skill = Read-Host"Choice"
  74. }
  75. switch ( $skill )
  76. {
  77. "1" { Write-Host("You have selected Mortal Strike!`n") }
  78. "2" { Write-Host("You have selected Rage Strike!`n") }
  79. }
  80. }
  81.  
  82. function Mage
  83. {
  84. Write-Host "Select A skill"
  85. Write-Host "1) For Fireball"
  86. Write-Host "2) For Frostbolt"
  87. $skill = Read-Host "Skill"
  88. While ($skill -ne "1" -and $skill -ne "2" )
  89. {
  90. write-host "Invalid selection. Please choose 1 or 2"
  91. $skill = Read-Host"Choice"
  92. }
  93. switch ( $skill )
  94. {
  95. "1" { Write-Host("You have selected Fireball!`n") }
  96. "2" { Write-Host("You have selected Frostbolt!`n") }
  97. }
  98. }
  99.  
  100. if ($MenuChoice -eq "1")
  101. {
  102. Warrior
  103. }
  104. Else
  105. {
  106. Mage
  107. }
  108.  
  109. $Name = Read-Host ( "What is your name Hero?" )
  110. Write-Host ( "Your journey has finally begun young hero" )
Advertisement
Add Comment
Please, Sign In to add comment