Advertisement
Guest User

Untitled

a guest
Nov 9th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 5.21 KB | None | 0 0
  1. Module Module1
  2.     Dim location(9, 9), lootmap(9, 9), Cave1(4, 4) As String
  3.     Dim trapMap(9, 9), CanDebug, debug As Boolean
  4.     Dim Input, isdebug, playerName As String
  5.     Dim trapStrings() As String = {"trapmsg1", "trapmsg2", "trapmsg3"}
  6.     Dim TrapDmg() As Integer = {40, 20, 15}
  7.     Dim x, y, i, ii, counter, health, trapcount As Integer
  8.  
  9.     Sub Main()
  10.         Conf()
  11.         'populate land
  12.         Inputvars()
  13.         Populate()
  14.         TrapPop()
  15.         'insert game code.
  16.         Debugging()
  17.         Do
  18.             IsDead()
  19.             Console.Write("Input: ")
  20.             Input = Console.ReadLine()
  21.             Move()
  22.             HasFallen()
  23.             Trapcheck()
  24.             Console.WriteLine(location(x, y))
  25.             Console.WriteLine(x + 1 & "," & y + 1 & " " & health)
  26.             IsDead()
  27.         Loop Until x = 9 And y = 9
  28.         Finish()
  29.     End Sub
  30.  
  31.  
  32.     Sub IsDead()
  33.         If health <= 0 Then
  34.             Console.WriteLine("You Died")
  35.             Console.ReadLine()
  36.             End
  37.         End If
  38.     End Sub
  39.  
  40.  
  41.     Sub Move()
  42.         If Input.ToLower() = "north" Or Input.ToLower() = "n" Then
  43.             y = y + 1
  44.         ElseIf Input.ToLower() = "south" Or Input.ToLower() = "s" Then
  45.             y = y - 1
  46.         ElseIf Input.ToLower() = "east" Or Input.ToLower() = "e" Then
  47.             x = x + 1
  48.         ElseIf Input.ToLower() = "west" Or Input.ToLower() = "w" Then
  49.             x = x - 1
  50.         Else
  51.             Console.WriteLine("Unknown Command")
  52.         End If
  53.     End Sub
  54.  
  55.  
  56.     Sub HasFallen()
  57.         If x > 9 Then
  58.             x = x - 1
  59.             FallMsg()
  60.         ElseIf y > 9 Then
  61.             y = y - 1
  62.             FallMsg()
  63.         ElseIf x < 0 Then
  64.             x = x + 1
  65.             FallMsg()
  66.         ElseIf y < 0 Then
  67.             y = y + 1
  68.             FallMsg()
  69.         End If
  70.     End Sub
  71.  
  72.  
  73.     Sub FallMsg()
  74.         health = health - (health / 2)
  75.         If health <= 0 Then
  76.             Console.WriteLine("You need help, you died by falling off the edge of the world.")
  77.             Console.ReadLine()
  78.             End
  79.         End If
  80.         Console.WriteLine("You fell off the world and lost 50% of your health, Don't do it again!")
  81.     End Sub
  82.  
  83.  
  84.     Sub Inputvars()
  85.         Console.Write("Username:")
  86.         playerName = Console.ReadLine()
  87.         If playerName = "Dev001" Then
  88.             CanDebug = True
  89.         Else
  90.             CanDebug = False
  91.         End If
  92.  
  93.         'Traps
  94.         Console.Write("How Many possible Traps would you like on the map? (max = 100): ")
  95.         Try
  96.             trapcount = Console.ReadLine() - 1
  97.         Catch e As Exception
  98.             Console.WriteLine("String or Null value Inserted. The process will be terminated.")
  99.             Console.ReadLine()
  100.             End
  101.         End Try
  102.         If trapcount > 100 Then
  103.             Console.WriteLine("You Put over 100 in, Goodbye. [Terminated]")
  104.             Console.ReadLine()
  105.             End
  106.         End If
  107.  
  108.         'Debug
  109.         If canDebug = True Then
  110.             Console.WriteLine("Enable Debugging? (y/n)")
  111.             isdebug = Console.ReadLine()
  112.             If String.IsNullOrEmpty(isdebug) Then
  113.                 debug = False
  114.             ElseIf isdebug.ToLower().First = "y" Then
  115.                 debug = True
  116.             Else
  117.                 debug = False
  118.             End If
  119.         End If
  120.  
  121.     End Sub
  122.  
  123.  
  124.     Sub Traps()
  125.         trapMap(Randint(), Randint()) = True
  126.     End Sub
  127.  
  128.  
  129.     Sub Trapcheck()
  130.         If trapMap(x, y) = True Then
  131.             Console.WriteLine(trapStrings(Int(Rnd() * trapStrings.Length)))
  132.             health = health - TrapDmg(Int(Rnd() * TrapDmg.Length))
  133.             trapMap(x, y) = False
  134.             If debug = True Then
  135.                 Console.WriteLine("Trap at: " & x & "," & y & " Removed")
  136.             End If
  137.         End If
  138.     End Sub
  139.  
  140.  
  141.     Sub TrapPop()
  142.         For i = 0 To 9
  143.             For ii = 0 To 9
  144.                 trapMap(i, ii) = False
  145.             Next
  146.         Next
  147.         For counter = 0 To trapcount
  148.             Traps()
  149.         Next
  150.     End Sub
  151.  
  152.  
  153.     Sub Populate()
  154.         For i = 0 To 9
  155.             For ii = 0 To 9
  156.                 location(ii, i) = "Empty Land"
  157.             Next
  158.         Next
  159.     End Sub
  160.  
  161.  
  162.     Function Randint()
  163.         Return Int(Rnd() * 10)
  164.     End Function
  165.  
  166.  
  167.  
  168.     Sub Finish()
  169.         Console.Write("End OF TBA, Press enter to continue.")
  170.         Console.ReadLine()
  171.     End Sub
  172.  
  173.  
  174.     Sub Debugging()
  175.         'debug land check
  176.         If debug = True Then
  177.             For i = 0 To 9
  178.                 For ii = 0 To 9
  179.                     Console.WriteLine("(" & ii & "," & i & "): " & location(ii, i) & " " & trapMap(i, ii))
  180.                 Next
  181.             Next
  182.         End If
  183.     End Sub
  184.  
  185.  
  186.     Sub Conf()
  187.         Console.Title = "Text Based Adventure"
  188.         Console.ForegroundColor = ConsoleColor.White
  189.         Console.BackgroundColor = ConsoleColor.DarkBlue
  190.         Console.WindowWidth = Console.LargestWindowWidth / 1.5
  191.         Console.WindowHeight = Console.LargestWindowHeight / 1.5
  192.         Console.Clear()
  193.         health = 100
  194.         x = 0
  195.         y = 0
  196.         counter = 0
  197.         i = 0
  198.         ii = 0
  199.     End Sub
  200.  
  201. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement