1 / 8

射擊 遊戲

射擊 遊戲. 南台科技大學 機械工程系 自動化控制 組 學 號 : 4A212110 沈冠 維. 產品動機. 做 這個遊戲的目的是,希望在空閒的時間可以和朋友有一個可以打發時間的遊戲或是可以永朋友促進友誼關係 。. 遊戲玩法說明. 隨機出現標 靶. 分數和 時間. 程式碼說明. 01 Dim CircleX , CircleY 02 Private Sub Command1_Click() 03 Command1.Enabled = False ' 禁止重複按 04

Download Presentation

射擊 遊戲

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 射擊遊戲 南台科技大學 機械工程系 自動化控制組 學號:4A212110 沈冠維

  2. 產品動機 • 做這個遊戲的目的是,希望在空閒的時間可以和朋友有一個可以打發時間的遊戲或是可以永朋友促進友誼關係。

  3. 遊戲玩法說明 隨機出現標靶 分數和時間

  4. 程式碼說明 • 01 • Dim CircleX, CircleY • 02 • Private Sub Command1_Click() • 03 • Command1.Enabled = False ' 禁止重複按 • 04 • Label1.Caption = 20 ' 時間 • 05 • Label2.Caption = 0 ' 分數 • 06 • Timer1.Enabled = True ' 啟動倒數計時 • 07 • Timer2.Enabled = True ' 啟動標靶 • 08 • End Sub

  5. 09 10 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) 11 ' 數學公式:(H-X)^2 + (K-Y)^2 <= R^2 等於點的位置在 半徑R 範圍裡面 12 If ((CircleX - X) ^ 2 + (CircleY - Y) ^ 2) <= 300 ^ 2 Then Label2 = Label2 + 8 ' 在範圍 300 內 + 8 分 13 If ((CircleX - X) ^ 2 + (CircleY - Y) ^ 2) <= 200 ^ 2 Then Label2 = Label2 + 1 ' 又在範圍 200 內 多加一分 = 9分 14 If ((CircleX' 關閉倒數計時 26 程式碼說明 • 09 • 10 • Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) • 11 • ' 數學公式:(H-X)^2 + (K-Y)^2 <= R^2 等於點的位置在 半徑R 範圍裡面 • 12 • If ((CircleX - X) ^ 2 + (CircleY - Y) ^ 2) <= 300 ^ 2 Then Label2 = Label2 + 8 ' 在範圍 300 內 + 8 分 • 13 • If ((CircleX - X) ^ 2 + (CircleY - Y) ^ 2) <= 200 ^ 2 Then Label2 = Label2 + 1 ' 又在範圍 200 內 多加一分 = 9分 • 14 • If ((CircleX - X) ^ 2 + (CircleY - Y) ^ 2) <= 100 ^ 2 Then Label2 = Label2 + 1 ' 又在範圍 100 內 多加一分 = 10分 • 15 • Cls ' 只給一次打中或沒打中的機會 • 16 • End Sub

  6. 程式碼說明 Private Sub Timer1_Timer() 19 Label1.Caption = Val(Label1) - 1 20 If Label1.Caption = 0 Then 21 Cls 22 CircleX = -9999999 ' 防止遊戲結束後點位置會加分 23 CircleY = -9999999 ' 防止遊戲結束後點位置會加分 24 MsgBox "時間到!", , "遊戲結束" 25 Timer1.Enabled = False ' 關閉倒數計時 26 Timer2.Enabled = False ' 關閉標靶 27 Command1.Enabled = True ' 重新開始遊戲 28 End If 29 End Sub

  7. 程式碼說明 Private Sub Timer2_Timer() 32 Cls ' 清空畫面 33 Me.Scale (0, 5000)-(5000, 0) 34 CircleX = 300 + Int(Rnd * 3001) 35 CircleY = 500 + Int(Rnd * 3001) 36 37 Circle (CircleX, CircleY), 100 38 Circle (CircleX, CircleY), 200 39 Circle (CircleX, CircleY), 300 40 End Sub

  8. 上課心得 謝謝老師用心的教導,雖然這個遊戲看似平凡但我想這是我這學期學到最有成就感的一科!

More Related