Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- 'PETER CARPENTER'S PACMAN
- Dim maze(20, 11), direction As Char
- Dim pacmanx, pacmany, scoreval, counter, timewaster As Integer
- Dim timewaster2 As String
- Sub Main()
- ' My.Computer.Audio.Play(My.Resources.dp_pacmania, AudioPlayMode.BackgroundLoop)
- Console.WindowWidth = 42
- Console.WindowHeight = 25
- Console.BufferHeight = 25
- Console.BufferWidth = 42
- Console.CursorVisible = False
- generate()
- Do
- display()
- move()
- score()
- counter = counter + 1
- Loop
- End Sub
- Sub generate()
- For x = 1 To 20
- maze(x, 1) = "#"
- maze(x, 11) = "#"
- Next
- For y = 2 To 10
- maze(1, y) = "#"
- maze(20, y) = "#"
- Next
- ‘Peter Carpenter
- maze(6, 2) = "#"
- maze(6, 3) = "#"
- maze(6, 9) = "#"
- maze(6, 10) = "#"
- maze(15, 2) = "#"
- maze(15, 3) = "#"
- maze(15, 9) = "#"
- maze(15, 10) = "#"
- maze(8, 3) = "#"
- maze(9, 3) = "#"
- maze(10, 3) = "#"
- maze(11, 3) = "#"
- maze(12, 3) = "#"
- maze(13, 3) = "#"
- maze(8, 9) = "#"
- maze(9, 9) = "#"
- maze(10, 9) = "#"
- maze(11, 9) = "#"
- maze(12, 9) = "#"
- maze(13, 9) = "#"
- maze(4, 3) = "#"
- maze(3, 3) = "#"
- maze(3, 4) = "#"
- maze(3, 5) = "#"
- maze(4, 9) = "#"
- maze(3, 9) = "#"
- maze(3, 8) = "#"
- maze(3, 7) = "#"
- maze(18, 3) = "#"
- maze(17, 3) = "#"
- maze(18, 4) = "#"
- maze(18, 5) = "#"
- maze(18, 9) = "#"
- maze(17, 9) = "#"
- maze(18, 8) = "#"
- maze(18, 7) = "#"
- maze(5, 5) = "#"
- maze(6, 5) = "#"
- maze(5, 7) = "#"
- maze(6, 7) = "#"
- maze(15, 5) = "#"
- maze(16, 5) = "#"
- maze(15, 7) = "#"
- maze(16, 7) = "#"
- maze(8, 7) = "#"
- maze(9, 7) = "#"
- maze(10, 7) = "#"
- maze(11, 7) = "#"
- maze(12, 7) = "#"
- maze(13, 7) = "#"
- maze(8, 6) = "#"
- maze(8, 5) = "#"
- maze(13, 6) = "#"
- maze(13, 5) = "#"
- maze(9, 5) = "#"
- maze(12, 5) = "#"
- pacmanx = 2
- pacmany = 2
- For x = 1 To 20
- For y = 1 To 11
- If maze(x, y) <> "#" And maze(x, y) <> "@" Then
- maze(x, y) = "."
- End If
- Next
- Next
- maze(10, 5) = " "
- maze(11, 5) = " "
- maze(9, 6) = " "
- maze(10, 6) = " "
- maze(11, 6) = " "
- maze(12, 6) = " "
- maze(7, 2) = "$"
- maze(14, 2) = "$"
- maze(7, 10) = "$"
- maze(14, 10) = "$"
- ‘Peter Carpenter
- End Sub
- Sub display()
- maze(pacmanx, pacmany) = "@"
- For x = 1 To 20
- For y = 1 To 11
- If x = pacmanx And y = pacmany Then
- Console.ForegroundColor = ConsoleColor.Yellow
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.ForegroundColor = ConsoleColor.Gray
- ElseIf maze(x, y) = "." Then
- Console.ForegroundColor = ConsoleColor.Red
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.ForegroundColor = ConsoleColor.Gray
- ElseIf maze(x, y) = "$" Then
- Console.ForegroundColor = ConsoleColor.Blue
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.ForegroundColor = ConsoleColor.Gray
- Else
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x - 1
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 2
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- Console.CursorTop = 2 * y - 1
- Console.CursorLeft = 2 * x
- Console.WriteLine(maze(x, y))
- End If
- Next
- Next
- ‘Peter Carpenter
- End Sub
- Sub move()
- For x = 1 To 1000
- timewaster = ((1000 - x) / 2) * 2
- timewaster2 = timewaster2 & " 33"
- Next
- maze(pacmanx, pacmany) = " "
- If Console.KeyAvailable = True Then
- Select Case Console.ReadKey.Key
- Case ConsoleKey.UpArrow
- direction = "u"
- Case ConsoleKey.DownArrow
- direction = "d"
- Case ConsoleKey.LeftArrow
- direction = "l"
- Case ConsoleKey.RightArrow
- direction = "r"
- End Select
- ‘Peter Carpenter
- End If
- Select Case direction
- Case "u"
- If maze(pacmanx, pacmany - 1) <> "#" Then
- pacmany = pacmany - 1
- End If
- Case "d"
- If maze(pacmanx, pacmany + 1) <> "#" Then
- pacmany = pacmany + 1
- End If
- Case "l"
- If maze(pacmanx - 1, pacmany) <> "#" Then
- pacmanx = pacmanx - 1
- End If
- Case "r"
- If maze(pacmanx + 1, pacmany) <> "#" Then
- pacmanx = pacmanx + 1
- End If
- End Select
- ‘Peter Carpenter
- End Sub
- Sub score()
- '101
- Dim dots As Integer
- Dim suns As Integer
- Dim sunscore As Integer
- dots = 5
- suns = 0
- For x = 1 To 20
- For y = 1 To 11
- If maze(x, y) = "." Then
- dots = dots + 1
- ElseIf maze(x, y) = "$" Then
- suns = suns + 1
- End If
- Next
- Next
- ‘Peter Carpenter
- sunscore = (4 - suns) * 10
- scoreval = (101 - dots) + sunscore
- Console.CursorTop = 23
- Console.CursorLeft = 2
- Console.WriteLine(" ")
- Console.CursorTop = 23
- Console.CursorLeft = 2
- Console.WriteLine("Score: " & scoreval)
- End Sub
- End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement