Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Dim location(9, 9), lootmap(9, 9), Cave1(4, 4) As String
- Dim trapMap(9, 9), CanDebug, debug As Boolean
- Dim Input, isdebug, playerName As String
- Dim trapStrings() As String = {"trapmsg1", "trapmsg2", "trapmsg3"}
- Dim TrapDmg() As Integer = {40, 20, 15}
- Dim x, y, i, ii, counter, health, trapcount As Integer
- Sub Main()
- Conf()
- 'populate land
- Inputvars()
- Populate()
- TrapPop()
- 'insert game code.
- Debugging()
- Do
- IsDead()
- Console.Write("Input: ")
- Input = Console.ReadLine()
- Move()
- HasFallen()
- Trapcheck()
- Console.WriteLine(location(x, y))
- Console.WriteLine(x + 1 & "," & y + 1 & " " & health)
- IsDead()
- Loop Until x = 9 And y = 9
- Finish()
- End Sub
- Sub IsDead()
- If health <= 0 Then
- Console.WriteLine("You Died")
- Console.ReadLine()
- End
- End If
- End Sub
- Sub Move()
- If Input.ToLower() = "north" Or Input.ToLower() = "n" Then
- y = y + 1
- ElseIf Input.ToLower() = "south" Or Input.ToLower() = "s" Then
- y = y - 1
- ElseIf Input.ToLower() = "east" Or Input.ToLower() = "e" Then
- x = x + 1
- ElseIf Input.ToLower() = "west" Or Input.ToLower() = "w" Then
- x = x - 1
- Else
- Console.WriteLine("Unknown Command")
- End If
- End Sub
- Sub HasFallen()
- If x > 9 Then
- x = x - 1
- FallMsg()
- ElseIf y > 9 Then
- y = y - 1
- FallMsg()
- ElseIf x < 0 Then
- x = x + 1
- FallMsg()
- ElseIf y < 0 Then
- y = y + 1
- FallMsg()
- End If
- End Sub
- Sub FallMsg()
- health = health - (health / 2)
- If health <= 0 Then
- Console.WriteLine("You need help, you died by falling off the edge of the world.")
- Console.ReadLine()
- End
- End If
- Console.WriteLine("You fell off the world and lost 50% of your health, Don't do it again!")
- End Sub
- Sub Inputvars()
- Console.Write("Username:")
- playerName = Console.ReadLine()
- If playerName = "Dev001" Then
- CanDebug = True
- Else
- CanDebug = False
- End If
- 'Traps
- Console.Write("How Many possible Traps would you like on the map? (max = 100): ")
- Try
- trapcount = Console.ReadLine() - 1
- Catch e As Exception
- Console.WriteLine("String or Null value Inserted. The process will be terminated.")
- Console.ReadLine()
- End
- End Try
- If trapcount > 100 Then
- Console.WriteLine("You Put over 100 in, Goodbye. [Terminated]")
- Console.ReadLine()
- End
- End If
- 'Debug
- If canDebug = True Then
- Console.WriteLine("Enable Debugging? (y/n)")
- isdebug = Console.ReadLine()
- If String.IsNullOrEmpty(isdebug) Then
- debug = False
- ElseIf isdebug.ToLower().First = "y" Then
- debug = True
- Else
- debug = False
- End If
- End If
- End Sub
- Sub Traps()
- trapMap(Randint(), Randint()) = True
- End Sub
- Sub Trapcheck()
- If trapMap(x, y) = True Then
- Console.WriteLine(trapStrings(Int(Rnd() * trapStrings.Length)))
- health = health - TrapDmg(Int(Rnd() * TrapDmg.Length))
- trapMap(x, y) = False
- If debug = True Then
- Console.WriteLine("Trap at: " & x & "," & y & " Removed")
- End If
- End If
- End Sub
- Sub TrapPop()
- For i = 0 To 9
- For ii = 0 To 9
- trapMap(i, ii) = False
- Next
- Next
- For counter = 0 To trapcount
- Traps()
- Next
- End Sub
- Sub Populate()
- For i = 0 To 9
- For ii = 0 To 9
- location(ii, i) = "Empty Land"
- Next
- Next
- End Sub
- Function Randint()
- Return Int(Rnd() * 10)
- End Function
- Sub Finish()
- Console.Write("End OF TBA, Press enter to continue.")
- Console.ReadLine()
- End Sub
- Sub Debugging()
- 'debug land check
- If debug = True Then
- For i = 0 To 9
- For ii = 0 To 9
- Console.WriteLine("(" & ii & "," & i & "): " & location(ii, i) & " " & trapMap(i, ii))
- Next
- Next
- End If
- End Sub
- Sub Conf()
- Console.Title = "Text Based Adventure"
- Console.ForegroundColor = ConsoleColor.White
- Console.BackgroundColor = ConsoleColor.DarkBlue
- Console.WindowWidth = Console.LargestWindowWidth / 1.5
- Console.WindowHeight = Console.LargestWindowHeight / 1.5
- Console.Clear()
- health = 100
- x = 0
- y = 0
- counter = 0
- i = 0
- ii = 0
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement