Form1.vb 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. Public Class Form1
  2. Dim time As Integer = 0
  3. Dim fish As Integer = 9
  4. Dim s As New Random
  5. Dim X1move As Integer = 1
  6. Dim Y1move As Integer = 1
  7. Dim X2move As Integer = 1
  8. Dim Y2move As Integer = 1
  9. Dim X3move As Integer = 1
  10. Dim Y3move As Integer = 1
  11. Dim X4move As Integer = 1
  12. Dim Y4move As Integer = 1
  13. Dim X5move As Integer = 1
  14. Dim Y5move As Integer = 1
  15. Dim X6move As Integer = 1
  16. Dim Y6move As Integer = 1
  17. Dim X7move As Integer = 1
  18. Dim Y7move As Integer = 1
  19. Dim X8move As Integer = 1
  20. Dim Y8move As Integer = 1
  21. Dim X9move As Integer = 1
  22. Dim Y9move As Integer = 1
  23. Dim difficulty
  24. Dim mode
  25. Dim mV As Integer = 0 '玩家游速(鍵盤模式)
  26. Dim V As Integer = 1 '其他魚游速
  27. Dim temp_x, temp_y As Integer
  28. Dim round As Integer = 1
  29. Dim best As Integer = 0
  30. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  31. My.Computer.Audio.Play(My.Resources.bgm, AudioPlayMode.BackgroundLoop)
  32. '在選擇難易度及操作方式之前,計時器及其他魚不能移動
  33. Timer1.Stop()
  34. Timer2.Stop()
  35. difficulty = MsgBox("請選擇遊戲難易度,此難易度決定魚的游速~" & vbCrLf & "是->簡單(正常游速)" & vbCrLf & "否->中等(2倍游速)" & vbCrLf & "取消->困難(3倍游速)", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Information, "難度選擇")
  36. If difficulty = MsgBoxResult.Yes Then
  37. mV = 2
  38. V = 2
  39. End If
  40. If difficulty = MsgBoxResult.No Then
  41. mV = 3
  42. V = 3
  43. End If
  44. If difficulty = MsgBoxResult.Cancel Then
  45. mV = 4
  46. V = 4
  47. End If
  48. mode = MsgBox("請選擇要用鍵盤還是滑鼠進行遊戲" & vbCrLf & "是->鍵盤(上下左右移動)" & vbCrLf & "否->滑鼠(滑鼠按住魚移動)", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "操作模式")
  49. If mode = MsgBoxResult.Yes Then
  50. PictureBox1.Enabled = False
  51. End If
  52. If mode = MsgBoxResult.No Then
  53. PictureBox1.Enabled = True
  54. mV = 0 '在滑鼠模式下不能用鍵盤移動(但可轉頭)
  55. If difficulty = MsgBoxResult.Yes Then
  56. V = 2
  57. End If
  58. If difficulty = MsgBoxResult.No Then
  59. V = 3
  60. End If
  61. If difficulty = MsgBoxResult.Cancel Then
  62. V = 4
  63. End If
  64. End If
  65. '遊戲正式開始
  66. Timer1.Start()
  67. Timer2.Start()
  68. PictureBox1.Image = My.Resources.a
  69. PictureBox2.Image = My.Resources.b
  70. PictureBox3.Image = My.Resources.c
  71. PictureBox4.Image = My.Resources.d
  72. PictureBox5.Image = My.Resources.e
  73. PictureBox6.Image = My.Resources.f
  74. PictureBox7.Image = My.Resources.g
  75. PictureBox8.Image = My.Resources.h
  76. PictureBox9.Image = My.Resources.i
  77. PictureBox10.Image = My.Resources.j
  78. PictureBox11.Image = My.Resources.trash
  79. PictureBox12.Image = My.Resources.trash
  80. PictureBox13.Image = My.Resources.trash
  81. PictureBox14.Image = My.Resources.trash
  82. PictureBox15.Image = My.Resources.trash
  83. PictureBox16.Image = My.Resources.trash
  84. PictureBox17.Image = My.Resources.trash
  85. PictureBox18.Image = My.Resources.grass
  86. PictureBox19.Image = My.Resources.grass
  87. PictureBox20.Image = My.Resources.grass
  88. PictureBox21.Image = My.Resources.grass
  89. PictureBox22.Image = My.Resources.grass
  90. Label2.Enabled = False
  91. Label7.Enabled = False
  92. Label12.Visible = False
  93. PictureBox1.Location = New Point(Me.ClientSize.Width / 2, Me.ClientSize.Height / 2)
  94. PictureBox2.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  95. PictureBox3.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  96. PictureBox4.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  97. PictureBox5.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  98. PictureBox6.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  99. PictureBox7.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  100. PictureBox8.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  101. PictureBox9.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  102. PictureBox10.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  103. PictureBox11.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  104. PictureBox12.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  105. PictureBox13.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  106. PictureBox14.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  107. PictureBox15.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  108. PictureBox16.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  109. PictureBox17.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  110. PictureBox18.Location = New Point(Me.ClientSize.Width / 6, Me.ClientSize.Height - 147)
  111. PictureBox19.Location = New Point(2 * (Me.ClientSize.Width / 6), Me.ClientSize.Height - 147)
  112. PictureBox20.Location = New Point(3 * (Me.ClientSize.Width / 6), Me.ClientSize.Height - 147)
  113. PictureBox21.Location = New Point(4 * (Me.ClientSize.Width / 6), Me.ClientSize.Height - 147)
  114. PictureBox22.Location = New Point(5 * (Me.ClientSize.Width / 6), Me.ClientSize.Height - 147)
  115. End Sub
  116. '鍵盤
  117. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  118. Select Case e.KeyCode
  119. Case 38 '上
  120. If Label1.Enabled = True Then
  121. If PictureBox1.Location.Y >= 0 Then
  122. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y - 10 * mV)
  123. End If
  124. Else '若遊戲暫停則玩家不能移動
  125. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y)
  126. End If
  127. Case 40 '下
  128. If Label1.Enabled = True Then
  129. If PictureBox1.Location.Y <= Me.ClientSize.Height - PictureBox1.Height Then
  130. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y + 10 * mV)
  131. End If
  132. Else '若遊戲暫停則玩家不能移動
  133. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y)
  134. End If
  135. Case 37 '左
  136. If Label1.Enabled = True Then
  137. If PictureBox1.Location.X >= 0 Then
  138. PictureBox1.Location = New Point(PictureBox1.Location.X - 10 * mV, PictureBox1.Location.Y)
  139. End If
  140. PictureBox1.Image = My.Resources.a '按下鍵盤"左"鍵,魚的頭朝向左邊
  141. Else '若遊戲暫停則玩家不能移動
  142. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y)
  143. End If
  144. Case 39 '右
  145. If Label1.Enabled = True Then
  146. If PictureBox1.Location.X < Me.ClientSize.Width - PictureBox1.Width Then
  147. PictureBox1.Location = New Point(PictureBox1.Location.X + 10 * mV, PictureBox1.Location.Y)
  148. End If
  149. PictureBox1.Image = My.Resources.a2 '按下鍵盤"右"鍵,魚的頭朝向右邊
  150. Else '若遊戲暫停則玩家不能移動
  151. PictureBox1.Location = New Point(PictureBox1.Location.X, PictureBox1.Location.Y)
  152. End If
  153. End Select
  154. End Sub
  155. '滑鼠
  156. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
  157. temp_x = e.X
  158. temp_y = e.Y
  159. End Sub
  160. Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
  161. If e.Button = MouseButtons.Left Then
  162. sender.Left += e.X - temp_x
  163. sender.Top += e.Y - temp_y
  164. End If
  165. End Sub
  166. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
  167. temp_x = 0
  168. temp_y = 0
  169. End Sub
  170. '其他魚撞到牆壁後會反彈
  171. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  172. For i As Integer = 1 To V
  173. PictureBox2.Left = PictureBox2.Left + X1move
  174. If PictureBox2.Left >= Me.ClientSize.Width - PictureBox2.Size.Width Or PictureBox2.Left <= 0 Then
  175. X1move = If(PictureBox2.Left <= 0, 2, -2)
  176. PictureBox2.Image = My.Resources.b2
  177. End If
  178. PictureBox2.Top = PictureBox2.Top + Y1move
  179. If PictureBox2.Top >= Me.ClientSize.Height - PictureBox2.Size.Height Or PictureBox2.Top <= 0 Then
  180. Y1move = If(PictureBox2.Top <= 0, 1, -1)
  181. PictureBox2.Image = My.Resources.b
  182. End If
  183. Next
  184. For i As Integer = 1 To V
  185. PictureBox3.Left = PictureBox3.Left + X2move
  186. If PictureBox3.Left >= Me.ClientSize.Width - PictureBox3.Size.Width Or PictureBox3.Left <= 0 Then
  187. X2move = If(PictureBox3.Left <= 0, 1, -1)
  188. PictureBox3.Image = My.Resources.c2
  189. End If
  190. PictureBox3.Top = PictureBox3.Top + Y2move
  191. If PictureBox3.Top >= Me.ClientSize.Height - PictureBox3.Size.Height Or PictureBox3.Top <= 0 Then
  192. Y2move = If(PictureBox3.Top <= 0, 1, -1)
  193. PictureBox3.Image = My.Resources.c
  194. End If
  195. Next
  196. For i As Integer = 1 To V
  197. PictureBox4.Left = PictureBox4.Left + X3move
  198. If PictureBox4.Left >= Me.ClientSize.Width - PictureBox4.Size.Width Or PictureBox4.Left <= 0 Then
  199. X3move = If(PictureBox4.Left <= 0, 2, -2)
  200. PictureBox4.Image = My.Resources.d2
  201. End If
  202. PictureBox4.Top = PictureBox4.Top + Y3move
  203. If PictureBox4.Top >= Me.ClientSize.Height - PictureBox4.Size.Height Or PictureBox4.Top <= 0 Then
  204. Y3move = If(PictureBox4.Top <= 0, 1, -1)
  205. PictureBox4.Image = My.Resources.d
  206. End If
  207. Next
  208. For i As Integer = 1 To V
  209. PictureBox5.Left = PictureBox5.Left + X4move
  210. If PictureBox5.Left >= Me.ClientSize.Width - PictureBox5.Size.Width Or PictureBox5.Left <= 0 Then
  211. X4move = If(PictureBox5.Left <= 0, 1, -1)
  212. PictureBox5.Image = My.Resources.e
  213. End If
  214. PictureBox5.Top = PictureBox5.Top + Y4move
  215. If PictureBox5.Top >= Me.ClientSize.Height - PictureBox5.Size.Height Or PictureBox5.Top <= 0 Then
  216. Y4move = If(PictureBox5.Top <= 0, 1, -1)
  217. PictureBox5.Image = My.Resources.e2
  218. End If
  219. Next
  220. For i As Integer = 1 To V
  221. PictureBox6.Left = PictureBox6.Left + X5move
  222. If PictureBox6.Left >= Me.ClientSize.Width - PictureBox6.Size.Width Or PictureBox6.Left <= 0 Then
  223. X5move = If(PictureBox6.Left <= 0, 2, -2)
  224. PictureBox6.Image = My.Resources.f
  225. End If
  226. PictureBox6.Top = PictureBox6.Top + Y5move
  227. If PictureBox6.Top >= Me.ClientSize.Height - PictureBox6.Size.Height Or PictureBox6.Top <= 0 Then
  228. Y5move = If(PictureBox6.Top <= 0, 1, -1)
  229. PictureBox6.Image = My.Resources.f2
  230. End If
  231. Next
  232. For i As Integer = 1 To V
  233. PictureBox7.Left = PictureBox7.Left + X6move
  234. If PictureBox7.Left >= Me.ClientSize.Width - PictureBox7.Size.Width Or PictureBox7.Left <= 0 Then
  235. X6move = If(PictureBox7.Left <= 0, 2, -2)
  236. PictureBox7.Image = My.Resources.g
  237. End If
  238. PictureBox7.Top = PictureBox7.Top + Y6move
  239. If PictureBox7.Top >= Me.ClientSize.Height - PictureBox7.Size.Height Or PictureBox7.Top <= 0 Then
  240. Y6move = If(PictureBox7.Top <= 0, 1, -1)
  241. PictureBox7.Image = My.Resources.g2
  242. End If
  243. Next
  244. For i As Integer = 1 To V
  245. PictureBox8.Left = PictureBox8.Left + X7move
  246. If PictureBox8.Left >= Me.ClientSize.Width - PictureBox8.Size.Width Or PictureBox8.Left <= 0 Then
  247. X7move = If(PictureBox8.Left <= 0, 2, -2)
  248. PictureBox8.Image = My.Resources.h
  249. End If
  250. PictureBox8.Top = PictureBox8.Top + Y7move
  251. If PictureBox8.Top >= Me.ClientSize.Height - PictureBox8.Size.Height Or PictureBox8.Top <= 0 Then
  252. Y7move = If(PictureBox8.Top <= 0, 1, -1)
  253. PictureBox8.Image = My.Resources.h2
  254. End If
  255. Next
  256. For i As Integer = 1 To V
  257. PictureBox9.Left = PictureBox9.Left + X8move
  258. If PictureBox9.Left >= Me.ClientSize.Width - PictureBox9.Size.Width Or PictureBox9.Left <= 0 Then
  259. X8move = If(PictureBox9.Left <= 0, 2, -2)
  260. PictureBox9.Image = My.Resources.i
  261. End If
  262. PictureBox9.Top = PictureBox9.Top + Y8move
  263. If PictureBox9.Top >= Me.ClientSize.Height - PictureBox9.Size.Height Or PictureBox9.Top <= 0 Then
  264. Y8move = If(PictureBox9.Top <= 0, 2, -2)
  265. PictureBox9.Image = My.Resources.i2
  266. End If
  267. Next
  268. For i As Integer = 1 To V
  269. PictureBox10.Left = PictureBox10.Left + X9move
  270. If PictureBox10.Left >= Me.ClientSize.Width - PictureBox10.Size.Width Or PictureBox10.Left <= 0 Then
  271. X9move = If(PictureBox10.Left <= 0, 2, -2)
  272. PictureBox10.Image = My.Resources.j
  273. End If
  274. PictureBox10.Top = PictureBox10.Top + Y9move
  275. If PictureBox10.Top >= Me.ClientSize.Height - PictureBox10.Size.Height Or PictureBox10.Top <= 0 Then
  276. Y9move = If(PictureBox10.Top <= 0, 2, -2)
  277. PictureBox10.Image = My.Resources.j2
  278. End If
  279. Next
  280. '吃魚判定.吃垃圾判定
  281. If (PictureBox1.Left <= PictureBox2.Left + PictureBox2.Width) And (PictureBox1.Left >= PictureBox2.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox2.Top + PictureBox2.Height) And (PictureBox1.Top >= PictureBox2.Top - PictureBox1.Height) Then
  282. If PictureBox1.Width > PictureBox2.Width Then
  283. PictureBox2.Visible = False
  284. End If
  285. If PictureBox1.Width <= PictureBox2.Width And PictureBox2.Visible = True Then
  286. If time > 3 Then '前3秒無敵
  287. PictureBox1.Visible = False
  288. End If
  289. End If
  290. End If
  291. If (PictureBox1.Left <= PictureBox3.Left + PictureBox3.Width) And (PictureBox1.Left >= PictureBox3.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox3.Top + PictureBox3.Height) And (PictureBox1.Top >= PictureBox3.Top - PictureBox1.Height) Then
  292. If PictureBox1.Width > PictureBox3.Width Then
  293. PictureBox3.Visible = False
  294. End If
  295. If PictureBox1.Width <= PictureBox3.Width And PictureBox3.Visible = True Then
  296. If time > 3 Then
  297. PictureBox1.Visible = False
  298. End If
  299. End If
  300. End If
  301. If (PictureBox1.Left <= PictureBox4.Left + PictureBox4.Width) And (PictureBox1.Left >= PictureBox4.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox4.Top + PictureBox4.Height) And (PictureBox1.Top >= PictureBox4.Top - PictureBox1.Height) Then
  302. If PictureBox1.Width > PictureBox4.Width Then
  303. PictureBox4.Visible = False
  304. End If
  305. If PictureBox1.Width <= PictureBox4.Width And PictureBox4.Visible = True Then
  306. If time > 3 Then
  307. PictureBox1.Visible = False
  308. End If
  309. End If
  310. End If
  311. If (PictureBox1.Left <= PictureBox5.Left + PictureBox5.Width) And (PictureBox1.Left >= PictureBox5.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox5.Top + PictureBox5.Height) And (PictureBox1.Top >= PictureBox5.Top - PictureBox1.Height) Then
  312. If PictureBox1.Width > PictureBox5.Width Then
  313. PictureBox5.Visible = False
  314. End If
  315. If PictureBox1.Width <= PictureBox5.Width And PictureBox5.Visible = True Then
  316. If time > 3 Then
  317. PictureBox1.Visible = False
  318. End If
  319. End If
  320. End If
  321. If (PictureBox1.Left <= PictureBox6.Left + PictureBox6.Width) And (PictureBox1.Left >= PictureBox6.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox6.Top + PictureBox6.Height) And (PictureBox1.Top >= PictureBox6.Top - PictureBox1.Height) Then
  322. If PictureBox1.Width > PictureBox6.Width Then
  323. PictureBox6.Visible = False
  324. End If
  325. If PictureBox1.Width <= PictureBox6.Width And PictureBox6.Visible = True Then
  326. If time > 3 Then
  327. PictureBox1.Visible = False
  328. End If
  329. End If
  330. End If
  331. If (PictureBox1.Left <= PictureBox7.Left + PictureBox7.Width) And (PictureBox1.Left >= PictureBox7.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox7.Top + PictureBox7.Height) And (PictureBox1.Top >= PictureBox7.Top - PictureBox1.Height) Then
  332. If PictureBox1.Width > PictureBox7.Width Then
  333. PictureBox7.Visible = False
  334. End If
  335. If PictureBox1.Width <= PictureBox7.Width And PictureBox7.Visible = True Then
  336. If time > 3 Then
  337. PictureBox1.Visible = False
  338. End If
  339. End If
  340. End If
  341. If (PictureBox1.Left <= PictureBox8.Left + PictureBox8.Width) And (PictureBox1.Left >= PictureBox8.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox8.Top + PictureBox8.Height) And (PictureBox1.Top >= PictureBox8.Top - PictureBox1.Height) Then
  342. If PictureBox1.Width > PictureBox8.Width Then
  343. PictureBox8.Visible = False
  344. End If
  345. If PictureBox1.Width <= PictureBox8.Width And PictureBox8.Visible = True Then
  346. If time > 3 Then
  347. PictureBox1.Visible = False
  348. End If
  349. End If
  350. End If
  351. If (PictureBox1.Left <= PictureBox9.Left + PictureBox9.Width) And (PictureBox1.Left >= PictureBox9.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox9.Top + PictureBox9.Height) And (PictureBox1.Top >= PictureBox9.Top - PictureBox1.Height) Then
  352. If PictureBox1.Width > PictureBox9.Width Then
  353. PictureBox9.Visible = False
  354. End If
  355. If PictureBox1.Width <= PictureBox9.Width And PictureBox9.Visible = True Then
  356. If time > 3 Then
  357. PictureBox1.Visible = False
  358. End If
  359. End If
  360. End If
  361. If (PictureBox1.Left <= PictureBox10.Left + PictureBox10.Width) And (PictureBox1.Left >= PictureBox10.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox10.Top + PictureBox10.Height) And (PictureBox1.Top >= PictureBox10.Top - PictureBox1.Height) Then
  362. If PictureBox1.Width > PictureBox10.Width Then
  363. PictureBox10.Visible = False
  364. End If
  365. If PictureBox1.Width <= PictureBox10.Width And PictureBox10.Visible = True Then
  366. If time > 3 Then
  367. PictureBox1.Visible = False
  368. End If
  369. End If
  370. End If
  371. If (PictureBox1.Left <= PictureBox11.Left + PictureBox11.Width) And (PictureBox1.Left >= PictureBox11.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox11.Top + PictureBox11.Height) And (PictureBox1.Top >= PictureBox11.Top - PictureBox1.Height) Then
  372. If time > 3 Then
  373. PictureBox11.Visible = False
  374. End If
  375. End If
  376. If (PictureBox1.Left <= PictureBox12.Left + PictureBox12.Width) And (PictureBox1.Left >= PictureBox12.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox12.Top + PictureBox12.Height) And (PictureBox1.Top >= PictureBox12.Top - PictureBox1.Height) Then
  377. If time > 3 Then
  378. PictureBox12.Visible = False
  379. End If
  380. End If
  381. If (PictureBox1.Left <= PictureBox13.Left + PictureBox13.Width) And (PictureBox1.Left >= PictureBox13.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox13.Top + PictureBox13.Height) And (PictureBox1.Top >= PictureBox13.Top - PictureBox1.Height) Then
  382. If time > 3 Then
  383. PictureBox13.Visible = False
  384. End If
  385. End If
  386. If (PictureBox1.Left <= PictureBox14.Left + PictureBox14.Width) And (PictureBox1.Left >= PictureBox14.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox14.Top + PictureBox14.Height) And (PictureBox1.Top >= PictureBox14.Top - PictureBox1.Height) Then
  387. If time > 3 Then
  388. PictureBox14.Visible = False
  389. End If
  390. End If
  391. If (PictureBox1.Left <= PictureBox15.Left + PictureBox15.Width) And (PictureBox1.Left >= PictureBox15.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox15.Top + PictureBox15.Height) And (PictureBox1.Top >= PictureBox15.Top - PictureBox1.Height) Then
  392. If time > 3 Then
  393. PictureBox15.Visible = False
  394. End If
  395. End If
  396. If (PictureBox1.Left <= PictureBox16.Left + PictureBox16.Width) And (PictureBox1.Left >= PictureBox16.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox16.Top + PictureBox16.Height) And (PictureBox1.Top >= PictureBox16.Top - PictureBox1.Height) Then
  397. If time > 3 Then
  398. PictureBox16.Visible = False
  399. End If
  400. End If
  401. If (PictureBox1.Left <= PictureBox17.Left + PictureBox17.Width) And (PictureBox1.Left >= PictureBox17.Left - PictureBox1.Width) And (PictureBox1.Top <= PictureBox17.Top + PictureBox17.Height) And (PictureBox1.Top >= PictureBox17.Top - PictureBox1.Height) Then
  402. If time > 3 Then
  403. PictureBox17.Visible = False
  404. End If
  405. End If
  406. End Sub
  407. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click '暫停
  408. Timer1.Stop()
  409. Timer2.Stop()
  410. Label1.Enabled = False
  411. Label2.Enabled = True
  412. PictureBox1.Enabled = False
  413. Label3.Text = "遊戲暫停"
  414. End Sub
  415. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click '開始
  416. Timer1.Start()
  417. Timer2.Start()
  418. Label2.Enabled = False
  419. Label1.Enabled = True
  420. If mode = MsgBoxResult.No Then
  421. PictureBox1.Enabled = True
  422. End If
  423. Label3.Text = ""
  424. End Sub
  425. Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick '計時
  426. time += 1
  427. Label4.Text = Format(time, "00")
  428. End Sub
  429. Private Sub p1_Tick(sender As Object, e As EventArgs) Handles p1.Tick '處理玩家的事件
  430. If PictureBox1.Visible = False Or PictureBox1.Size.Width <= 0 Then
  431. p1.Stop()
  432. Timer1.Stop()
  433. Timer2.Stop()
  434. My.Computer.Audio.Play(My.Resources.bgm2, AudioPlayMode.WaitToComplete)
  435. MsgBox("GAME OVER!!")
  436. My.Computer.Audio.Play(My.Resources.bgm, AudioPlayMode.BackgroundLoop)
  437. Label3.Text = "請重啟遊戲"
  438. Label1.Enabled = False
  439. Label7.Enabled = True
  440. End If
  441. End Sub
  442. Private Sub p2_Tick(sender As Object, e As EventArgs) Handles p2.Tick '處理其他魚1的事件
  443. If PictureBox2.Visible = False Then
  444. fish -= 1
  445. Label5.Text = Format(fish, "0")
  446. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox2.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox2.Size.Height) / 3)
  447. p2.Stop()
  448. End If
  449. End Sub
  450. Private Sub p3_Tick(sender As Object, e As EventArgs) Handles p3.Tick '處理其他魚2的事件
  451. If PictureBox3.Visible = False Then
  452. fish -= 1
  453. Label5.Text = Format(fish, "0")
  454. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox3.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox3.Size.Height) / 3)
  455. p3.Stop()
  456. End If
  457. End Sub
  458. Private Sub p4_Tick(sender As Object, e As EventArgs) Handles p4.Tick '處理其他魚3的事件
  459. If PictureBox4.Visible = False Then
  460. fish -= 1
  461. Label5.Text = Format(fish, "0")
  462. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox4.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox4.Size.Height) / 3)
  463. p4.Stop()
  464. End If
  465. End Sub
  466. Private Sub p5_Tick(sender As Object, e As EventArgs) Handles p5.Tick '處理其他魚4的事件
  467. If PictureBox5.Visible = False Then
  468. fish -= 1
  469. Label5.Text = Format(fish, "0")
  470. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox5.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox5.Size.Height) / 3)
  471. p5.Stop()
  472. End If
  473. End Sub
  474. Private Sub p6_Tick(sender As Object, e As EventArgs) Handles p6.Tick '處理其他魚5的事件
  475. If PictureBox6.Visible = False Then
  476. fish -= 1
  477. Label5.Text = Format(fish, "0")
  478. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox6.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox6.Size.Height) / 3)
  479. p6.Stop()
  480. End If
  481. End Sub
  482. Private Sub p7_Tick(sender As Object, e As EventArgs) Handles p7.Tick '處理其他魚6的事件
  483. If PictureBox7.Visible = False Then
  484. fish -= 1
  485. Label5.Text = Format(fish, "0")
  486. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox7.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox7.Size.Height) / 3)
  487. p7.Stop()
  488. End If
  489. End Sub
  490. Private Sub p8_Tick(sender As Object, e As EventArgs) Handles p8.Tick '處理其他魚7的事件
  491. If PictureBox8.Visible = False Then
  492. fish -= 1
  493. Label5.Text = Format(fish, "0")
  494. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox8.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox8.Size.Height) / 3)
  495. p8.Stop()
  496. End If
  497. End Sub
  498. Private Sub p9_Tick(sender As Object, e As EventArgs) Handles p9.Tick '處理其他魚8的事件
  499. If PictureBox9.Visible = False Then
  500. fish -= 1
  501. Label5.Text = Format(fish, "0")
  502. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox9.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox9.Size.Height) / 3)
  503. p9.Stop()
  504. End If
  505. End Sub
  506. Private Sub p10_Tick(sender As Object, e As EventArgs) Handles p10.Tick '處理其他魚9的事件
  507. If PictureBox10.Visible = False Then
  508. fish -= 1
  509. Label5.Text = Format(fish, "0")
  510. PictureBox1.Size = New Size(PictureBox1.Size.Width + (PictureBox10.Size.Width) / 3, PictureBox1.Size.Height + (PictureBox10.Size.Height) / 3)
  511. p10.Stop()
  512. End If
  513. End Sub
  514. '處理垃圾1~7的事件
  515. Private Sub t1_Tick(sender As Object, e As EventArgs) Handles t1.Tick
  516. If PictureBox11.Visible = False And PictureBox1.Size.Width <= 100 Then
  517. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 5)
  518. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  519. t1.Stop()
  520. End If
  521. If PictureBox11.Visible = False And PictureBox1.Size.Width > 100 Then
  522. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  523. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  524. t1.Stop()
  525. End If
  526. End Sub
  527. Private Sub t2_Tick(sender As Object, e As EventArgs) Handles t2.Tick
  528. If PictureBox12.Visible = False And PictureBox1.Size.Width <= 100 Then
  529. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox12.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox12.Size.Height) / 5)
  530. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  531. t2.Stop()
  532. End If
  533. If PictureBox12.Visible = False And PictureBox1.Size.Width > 100 Then
  534. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  535. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  536. t2.Stop()
  537. End If
  538. End Sub
  539. Private Sub t3_Tick(sender As Object, e As EventArgs) Handles t3.Tick
  540. If PictureBox13.Visible = False And PictureBox1.Size.Width <= 100 Then
  541. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox13.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox13.Size.Height) / 5)
  542. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  543. t3.Stop()
  544. End If
  545. If PictureBox13.Visible = False And PictureBox1.Size.Width > 100 Then
  546. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  547. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  548. t3.Stop()
  549. End If
  550. End Sub
  551. Private Sub t4_Tick(sender As Object, e As EventArgs) Handles t4.Tick
  552. If PictureBox14.Visible = False And PictureBox1.Size.Width <= 100 Then
  553. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox14.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox14.Size.Height) / 5)
  554. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  555. t4.Stop()
  556. End If
  557. If PictureBox14.Visible = False And PictureBox1.Size.Width > 100 Then
  558. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  559. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  560. t4.Stop()
  561. End If
  562. End Sub
  563. Private Sub t5_Tick(sender As Object, e As EventArgs) Handles t5.Tick
  564. If PictureBox15.Visible = False And PictureBox1.Size.Width <= 100 Then
  565. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox15.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox15.Size.Height) / 5)
  566. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  567. t5.Stop()
  568. End If
  569. If PictureBox15.Visible = False And PictureBox1.Size.Width > 100 Then
  570. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  571. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  572. t5.Stop()
  573. End If
  574. End Sub
  575. Private Sub t6_Tick(sender As Object, e As EventArgs) Handles t6.Tick
  576. If PictureBox16.Visible = False And PictureBox1.Size.Width <= 100 Then
  577. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox16.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox16.Size.Height) / 5)
  578. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  579. t6.Stop()
  580. End If
  581. If PictureBox16.Visible = False And PictureBox1.Size.Width > 100 Then
  582. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  583. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  584. t6.Stop()
  585. End If
  586. End Sub
  587. Private Sub t7_Tick(sender As Object, e As EventArgs) Handles t7.Tick
  588. If PictureBox17.Visible = False And PictureBox1.Size.Width <= 100 Then
  589. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox17.Size.Width) / 5, PictureBox1.Size.Height - (PictureBox17.Size.Height) / 5)
  590. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  591. t7.Stop()
  592. End If
  593. If PictureBox14.Visible = False And PictureBox1.Size.Width > 100 Then
  594. PictureBox1.Size = New Size(PictureBox1.Size.Width - (PictureBox11.Size.Width) / 2, PictureBox1.Size.Height - (PictureBox11.Size.Height) / 2)
  595. My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Beep)
  596. t7.Stop()
  597. End If
  598. End Sub
  599. Private Sub GameClear_Tick(sender As Object, e As EventArgs) Handles GameClear.Tick '過關
  600. If PictureBox2.Visible = False And PictureBox3.Visible = False And PictureBox4.Visible = False And
  601. PictureBox5.Visible = False And PictureBox6.Visible = False And PictureBox7.Visible = False And
  602. PictureBox8.Visible = False And PictureBox9.Visible = False And PictureBox10.Visible = False Then
  603. GameClear.Stop()
  604. Timer1.Stop()
  605. Timer2.Stop()
  606. My.Computer.Audio.Play(My.Resources.bgm3, AudioPlayMode.WaitToComplete)
  607. MsgBox("恭喜通關!!")
  608. My.Computer.Audio.Play(My.Resources.bgm, AudioPlayMode.BackgroundLoop)
  609. Label3.Text = "請重啟遊戲"
  610. Label1.Enabled = False
  611. Label7.Enabled = True
  612. If time < best Or best = 0 Then '最佳成績判斷
  613. best = time
  614. Label11.Text = Format(best, "00")
  615. End If
  616. End If
  617. End Sub
  618. Private Sub Label7_Click(sender As Object, e As EventArgs) Handles Label7.Click '重玩
  619. Dim s As New Random
  620. difficulty = MsgBox("請選擇遊戲難易度,此難易度決定魚的游速~" & vbCrLf & "是->簡單(正常游速)" & vbCrLf & "否->中等(2倍游速)" & vbCrLf & "取消->困難(3倍游速)", MsgBoxStyle.YesNoCancel + MsgBoxStyle.Information, "難度選擇")
  621. If difficulty = MsgBoxResult.Yes Then
  622. mV = 2
  623. V = 2
  624. End If
  625. If difficulty = MsgBoxResult.No Then
  626. mV = 4
  627. V = 4
  628. End If
  629. If difficulty = MsgBoxResult.Cancel Then
  630. mV = 6
  631. V = 6
  632. End If
  633. mode = MsgBox("請選擇要用鍵盤還是滑鼠進行遊戲" & vbCrLf & "是->鍵盤(上下左右移動)" & vbCrLf & "否->滑鼠(滑鼠按住魚移動)", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "操作模式")
  634. If mode = MsgBoxResult.Yes Then
  635. PictureBox1.Enabled = False
  636. End If
  637. If mode = MsgBoxResult.No Then
  638. PictureBox1.Enabled = True
  639. mV = 0
  640. If difficulty = MsgBoxResult.Yes Then
  641. V = 2
  642. End If
  643. If difficulty = MsgBoxResult.No Then
  644. V = 4
  645. End If
  646. If difficulty = MsgBoxResult.Cancel Then
  647. V = 6
  648. End If
  649. End If
  650. fish = 9
  651. Label5.Text = Format(fish, "0")
  652. time = 0
  653. Label4.Text = Format(time, "00")
  654. Label3.Text = ""
  655. round += 1
  656. Label9.Text = Format(round, "0")
  657. Timer1.Start()
  658. Timer2.Start()
  659. p1.Start()
  660. p2.Start()
  661. p3.Start()
  662. p4.Start()
  663. p5.Start()
  664. p6.Start()
  665. p7.Start()
  666. p8.Start()
  667. p9.Start()
  668. p10.Start()
  669. t1.Start()
  670. t2.Start()
  671. t3.Start()
  672. t4.Start()
  673. t5.Start()
  674. t6.Start()
  675. t7.Start()
  676. GameClear.Start()
  677. PictureBox1.Visible = True
  678. PictureBox2.Visible = True
  679. PictureBox3.Visible = True
  680. PictureBox4.Visible = True
  681. PictureBox5.Visible = True
  682. PictureBox6.Visible = True
  683. PictureBox7.Visible = True
  684. PictureBox8.Visible = True
  685. PictureBox9.Visible = True
  686. PictureBox10.Visible = True
  687. PictureBox11.Visible = True
  688. PictureBox12.Visible = True
  689. PictureBox13.Visible = True
  690. PictureBox14.Visible = True
  691. PictureBox15.Visible = True
  692. PictureBox16.Visible = True
  693. PictureBox17.Visible = True
  694. PictureBox1.Image = My.Resources.a
  695. PictureBox2.Image = My.Resources.b
  696. PictureBox3.Image = My.Resources.c
  697. PictureBox4.Image = My.Resources.d
  698. PictureBox5.Image = My.Resources.e
  699. PictureBox6.Image = My.Resources.f
  700. PictureBox7.Image = My.Resources.g
  701. PictureBox8.Image = My.Resources.h
  702. PictureBox9.Image = My.Resources.i
  703. PictureBox10.Image = My.Resources.j
  704. Label1.Enabled = True
  705. Label2.Enabled = False
  706. Label7.Enabled = False
  707. PictureBox1.Size = New Size(50, 50)
  708. PictureBox1.Location = New Point(Me.ClientSize.Width / 2, Me.ClientSize.Height / 2)
  709. PictureBox2.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  710. PictureBox3.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  711. PictureBox4.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  712. PictureBox5.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  713. PictureBox6.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  714. PictureBox7.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  715. PictureBox8.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  716. PictureBox9.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  717. PictureBox10.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  718. PictureBox11.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  719. PictureBox12.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  720. PictureBox13.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  721. PictureBox14.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  722. PictureBox15.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  723. PictureBox16.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  724. PictureBox17.Location = New Point(s.Next(Me.ClientSize.Width - 100), s.Next(Me.ClientSize.Height - 100))
  725. End Sub
  726. '秘密功能
  727. Private Sub PictureBox21_DoubleClick(sender As Object, e As EventArgs) Handles PictureBox21.DoubleClick
  728. Timer1.Stop()
  729. Timer2.Stop()
  730. MsgBox("秘密功能啟動!?")
  731. If Label1.Enabled = True Then
  732. Timer1.Start()
  733. Timer2.Start()
  734. End If
  735. Label12.Visible = True
  736. PictureBox21.Enabled = False '再次雙擊不會彈出MsgBox
  737. End Sub
  738. Private Sub Label12_Click(sender As Object, e As EventArgs) Handles Label12.Click
  739. PictureBox1.Size = New Size(PictureBox1.Size.Width + 10, PictureBox1.Size.Height + 10)
  740. End Sub
  741. End Class