Advertisement
ijontichy

derp.vb

Mar 3rd, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.89 KB | None | 0 0
  1. Module Module1
  2.  
  3. 'PETER CARPENTER'S PACMAN
  4. Dim maze(20, 11), direction As Char
  5. Dim pacmanx, pacmany, scoreval, counter, timewaster As Integer
  6. Dim timewaster2 As String
  7. Sub Main()
  8. ' My.Computer.Audio.Play(My.Resources.dp_pacmania, AudioPlayMode.BackgroundLoop)
  9. Console.WindowWidth = 42
  10. Console.WindowHeight = 25
  11. Console.BufferHeight = 25
  12. Console.BufferWidth = 42
  13. Console.CursorVisible = False
  14. generate()
  15. Do
  16. display()
  17. move()
  18. score()
  19. counter = counter + 1
  20. Loop
  21.  
  22. End Sub
  23. Sub generate()
  24. For x = 1 To 20
  25. maze(x, 1) = "#"
  26. maze(x, 11) = "#"
  27. Next
  28. For y = 2 To 10
  29. maze(1, y) = "#"
  30. maze(20, y) = "#"
  31. Next
  32. ‘Peter Carpenter
  33.  
  34. maze(6, 2) = "#"
  35. maze(6, 3) = "#"
  36. maze(6, 9) = "#"
  37. maze(6, 10) = "#"
  38. maze(15, 2) = "#"
  39. maze(15, 3) = "#"
  40. maze(15, 9) = "#"
  41. maze(15, 10) = "#"
  42. maze(8, 3) = "#"
  43. maze(9, 3) = "#"
  44. maze(10, 3) = "#"
  45. maze(11, 3) = "#"
  46. maze(12, 3) = "#"
  47. maze(13, 3) = "#"
  48. maze(8, 9) = "#"
  49. maze(9, 9) = "#"
  50. maze(10, 9) = "#"
  51. maze(11, 9) = "#"
  52. maze(12, 9) = "#"
  53. maze(13, 9) = "#"
  54. maze(4, 3) = "#"
  55. maze(3, 3) = "#"
  56. maze(3, 4) = "#"
  57. maze(3, 5) = "#"
  58. maze(4, 9) = "#"
  59. maze(3, 9) = "#"
  60. maze(3, 8) = "#"
  61. maze(3, 7) = "#"
  62. maze(18, 3) = "#"
  63. maze(17, 3) = "#"
  64. maze(18, 4) = "#"
  65. maze(18, 5) = "#"
  66. maze(18, 9) = "#"
  67. maze(17, 9) = "#"
  68. maze(18, 8) = "#"
  69. maze(18, 7) = "#"
  70. maze(5, 5) = "#"
  71. maze(6, 5) = "#"
  72. maze(5, 7) = "#"
  73. maze(6, 7) = "#"
  74. maze(15, 5) = "#"
  75. maze(16, 5) = "#"
  76. maze(15, 7) = "#"
  77. maze(16, 7) = "#"
  78. maze(8, 7) = "#"
  79. maze(9, 7) = "#"
  80. maze(10, 7) = "#"
  81. maze(11, 7) = "#"
  82. maze(12, 7) = "#"
  83. maze(13, 7) = "#"
  84. maze(8, 6) = "#"
  85. maze(8, 5) = "#"
  86. maze(13, 6) = "#"
  87. maze(13, 5) = "#"
  88. maze(9, 5) = "#"
  89. maze(12, 5) = "#"
  90. pacmanx = 2
  91. pacmany = 2
  92. For x = 1 To 20
  93. For y = 1 To 11
  94. If maze(x, y) <> "#" And maze(x, y) <> "@" Then
  95. maze(x, y) = "."
  96. End If
  97. Next
  98. Next
  99. maze(10, 5) = " "
  100. maze(11, 5) = " "
  101. maze(9, 6) = " "
  102. maze(10, 6) = " "
  103. maze(11, 6) = " "
  104. maze(12, 6) = " "
  105. maze(7, 2) = "$"
  106. maze(14, 2) = "$"
  107. maze(7, 10) = "$"
  108. maze(14, 10) = "$"
  109. ‘Peter Carpenter
  110.  
  111. End Sub
  112. Sub display()
  113. maze(pacmanx, pacmany) = "@"
  114. For x = 1 To 20
  115. For y = 1 To 11
  116. If x = pacmanx And y = pacmany Then
  117. Console.ForegroundColor = ConsoleColor.Yellow
  118. Console.CursorTop = 2 * y - 2
  119. Console.CursorLeft = 2 * x - 1
  120. Console.WriteLine(maze(x, y))
  121. Console.CursorTop = 2 * y - 1
  122. Console.CursorLeft = 2 * x - 1
  123. Console.WriteLine(maze(x, y))
  124. Console.CursorTop = 2 * y - 2
  125. Console.CursorLeft = 2 * x
  126. Console.WriteLine(maze(x, y))
  127. Console.CursorTop = 2 * y - 1
  128. Console.CursorLeft = 2 * x
  129. Console.WriteLine(maze(x, y))
  130. Console.ForegroundColor = ConsoleColor.Gray
  131. ElseIf maze(x, y) = "." Then
  132. Console.ForegroundColor = ConsoleColor.Red
  133. Console.CursorTop = 2 * y - 2
  134. Console.CursorLeft = 2 * x - 1
  135. Console.WriteLine(maze(x, y))
  136. Console.CursorTop = 2 * y - 1
  137. Console.CursorLeft = 2 * x - 1
  138. Console.WriteLine(maze(x, y))
  139. Console.CursorTop = 2 * y - 2
  140. Console.CursorLeft = 2 * x
  141. Console.WriteLine(maze(x, y))
  142. Console.CursorTop = 2 * y - 1
  143. Console.CursorLeft = 2 * x
  144. Console.WriteLine(maze(x, y))
  145. Console.ForegroundColor = ConsoleColor.Gray
  146. ElseIf maze(x, y) = "$" Then
  147. Console.ForegroundColor = ConsoleColor.Blue
  148. Console.CursorTop = 2 * y - 2
  149. Console.CursorLeft = 2 * x - 1
  150. Console.WriteLine(maze(x, y))
  151. Console.CursorTop = 2 * y - 1
  152. Console.CursorLeft = 2 * x - 1
  153. Console.WriteLine(maze(x, y))
  154. Console.CursorTop = 2 * y - 2
  155. Console.CursorLeft = 2 * x
  156. Console.WriteLine(maze(x, y))
  157. Console.CursorTop = 2 * y - 1
  158. Console.CursorLeft = 2 * x
  159. Console.WriteLine(maze(x, y))
  160. Console.ForegroundColor = ConsoleColor.Gray
  161. Else
  162. Console.CursorTop = 2 * y - 2
  163. Console.CursorLeft = 2 * x - 1
  164. Console.WriteLine(maze(x, y))
  165. Console.CursorTop = 2 * y - 1
  166. Console.CursorLeft = 2 * x - 1
  167. Console.WriteLine(maze(x, y))
  168. Console.CursorTop = 2 * y - 2
  169. Console.CursorLeft = 2 * x
  170. Console.WriteLine(maze(x, y))
  171. Console.CursorTop = 2 * y - 1
  172. Console.CursorLeft = 2 * x
  173. Console.WriteLine(maze(x, y))
  174. End If
  175. Next
  176. Next
  177. ‘Peter Carpenter
  178.  
  179. End Sub
  180. Sub move()
  181. For x = 1 To 1000
  182. timewaster = ((1000 - x) / 2) * 2
  183. timewaster2 = timewaster2 & " 33"
  184. Next
  185. maze(pacmanx, pacmany) = " "
  186. If Console.KeyAvailable = True Then
  187. Select Case Console.ReadKey.Key
  188. Case ConsoleKey.UpArrow
  189. direction = "u"
  190. Case ConsoleKey.DownArrow
  191. direction = "d"
  192. Case ConsoleKey.LeftArrow
  193. direction = "l"
  194. Case ConsoleKey.RightArrow
  195. direction = "r"
  196. End Select
  197. ‘Peter Carpenter
  198. End If
  199.  
  200. Select Case direction
  201. Case "u"
  202. If maze(pacmanx, pacmany - 1) <> "#" Then
  203. pacmany = pacmany - 1
  204. End If
  205. Case "d"
  206. If maze(pacmanx, pacmany + 1) <> "#" Then
  207. pacmany = pacmany + 1
  208. End If
  209. Case "l"
  210. If maze(pacmanx - 1, pacmany) <> "#" Then
  211. pacmanx = pacmanx - 1
  212. End If
  213. Case "r"
  214. If maze(pacmanx + 1, pacmany) <> "#" Then
  215. pacmanx = pacmanx + 1
  216. End If
  217. End Select
  218. ‘Peter Carpenter
  219. End Sub
  220. Sub score()
  221. '101
  222. Dim dots As Integer
  223. Dim suns As Integer
  224. Dim sunscore As Integer
  225. dots = 5
  226. suns = 0
  227. For x = 1 To 20
  228. For y = 1 To 11
  229. If maze(x, y) = "." Then
  230. dots = dots + 1
  231. ElseIf maze(x, y) = "$" Then
  232. suns = suns + 1
  233. End If
  234. Next
  235. Next
  236. ‘Peter Carpenter
  237. sunscore = (4 - suns) * 10
  238. scoreval = (101 - dots) + sunscore
  239. Console.CursorTop = 23
  240. Console.CursorLeft = 2
  241. Console.WriteLine(" ")
  242. Console.CursorTop = 23
  243. Console.CursorLeft = 2
  244. Console.WriteLine("Score: " & scoreval)
  245. End Sub
  246. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement