Presentation is loading. Please wait.

Presentation is loading. Please wait.

計算機程式及實習期末報告 VB 2010設計遊戲程式

Similar presentations


Presentation on theme: "計算機程式及實習期末報告 VB 2010設計遊戲程式"— Presentation transcript:

1 計算機程式及實習期末報告 VB 2010設計遊戲程式
題目: 歡迎光臨~家庭教師REBORN!翻牌遊戲 學校: 南台科技大學 班級: 車輛一甲 學號: 4A115098 姓名: 黃士軒 老師: 謝慶存

2 題目說明 首先開起執行檔後,會看到遊戲畫面,總共分成3個階級(高級、中級、初級),這3級有什麼特別的呢?
點擊高級的按鈕後,會開始倒數2秒,這個時候就要記住其中的圖示,假如配對錯誤,便會跳出『答錯了-.-+』的視窗,另外要注意,不是無時間限制的,3個階級的遊戲時限都是30秒鐘,假如超過,便會跳出『時間到,失敗了...你就給我抱著必死的決心吧!』。 而點擊中級,只是給的記憶時間變為5秒鐘,點級初級的有10秒鐘。 另外,假如過關了,就會有過關的配音。

3 卡牌圖

4 遊戲介面

5

6 表單(Form)

7 程式碼 Public Class Form1 Dim n() As Integer = {0, 1, 2, 4, 3, 3, 1, 4, 2} Dim p(8) As PictureBox Dim hitPic1, hitPic2 As PictureBox Dim t1, t2 As String Dim isFirst As Boolean = True Dim timer1Tot As Integer Dim timer2Tot As Integer Dim level As Integer Dim tot As Integer

8 Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink lblShow.Text = "請按[開始] 鈕進行遊戲﹐" lblTime.Text = "" Timer1.Interval = 1000 Timer2.Interval = 1000 p(1) = pic1 p(2) = pic2 p(3) = pic3 p(4) = pic4 p(5) = pic5 p(6) = pic6 p(7) = pic7 p(8) = pic8 For i = 1 To n.GetUpperBound(0) p(i).Image = New Bitmap("q.jpg") p(i).Tag = n(i) p(i).SizeMode = PictureBoxSizeMode.StretchImage p(i).BorderStyle = BorderStyle.Fixed3D p(i).Enabled = False Next

9 Private Sub pic1_Click(ByVal sender As System
Private Sub pic1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic8.Click, pic7.Click, pic6.Click, pic5.Click, pic4.Click, pic3.Click, pic2.Click, pic1.Click If isFirst Then hitPic1 = CType(sender, PictureBox) t1 = hitPic1.Tag.ToString hitPic1.Image = New Bitmap(hitPic1.Tag.ToString & ".jpg") isFirst = False Else hitPic2 = CType(sender, PictureBox) t2 = hitPic2.Tag.ToString hitPic2.Image = New Bitmap(hitPic2.Tag.ToString & ".jpg") isFirst = True If t1 = t2 Then hitPic1.Enabled = False hitPic2.Enabled = False tot += 1 My.Computer.Audio.Play("CHIMES.WAV", AudioPlayMode.Background) End If If t1 <> t2 Then MsgBox("答錯了-.-+) hitPic1.Image = New Bitmap("q.jpg") hitPic2.Image = New Bitmap("q.jpg") If tot = 4 Then btn1.Enabled = True btn2.Enabled = True btn3.Enabled = True Timer1.Enabled = False Timer2.Enabled = False If level = 2 Then MsgBox("過關了...果然是高手") ElseIf level = 5 Then MsgBox("過關了...你還不賴") ElseIf level = 10 Then MsgBox("過關了...看來你還需要特訓~") My.Computer.Audio.Play("APPLAUSE.WAV", AudioPlayMode.Background) End Sub

10 Private Sub GameStart()
My.Computer.Audio.Stop() level = timer1Tot btn1.Enabled = False btn2.Enabled = False btn3.Enabled = False Timer1.Enabled = True timer2Tot = 0 t1 = "" t2 = "" tot = 0 hitPic1 = Nothing hitPic2 = Nothing lblShow.Text = "你可以檢視的時間!還有 " & timer1Tot & "秒" lblTime.Text = "" For i = 1 To n.GetUpperBound(0) p(i).Image = New Bitmap(n(i) & ".jpg") Next End Sub

11 Private Sub btn1_Click(ByVal sender As System
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click timer1Tot = 2 GameStart() End Sub Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click timer1Tot = 5 Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click timer1Tot = 10

12 Private Sub Timer1_Tick(ByVal sender As System
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick timer1Tot -= 1 lblShow.Text = “你可以檢視的時間!還有 " & timer1Tot & "秒" If timer1Tot = 0 Then Timer1.Enabled = False lblShow.Text = "" Timer2.Enabled = True For i = 1 To n.GetUpperBound(0) p(i).Image = New Bitmap("q.jpg") p(i).Enabled = True Next End If End Sub

13 Private Sub Timer2_Tick(ByVal sender As System
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick timer2Tot += 1 lblTime.Text = "遊戲﹐時間:G" & timer2Tot & " 秒" If timer2Tot = 30 Then Timer2.Enabled = False btn1.Enabled = True btn2.Enabled = True btn3.Enabled = True MsgBox("時間到,失敗了...你就給我抱著必死的決心吧!") lblShow.Text = "請按 [開始] 鈕進行遊戲﹐" lblTime.Text = "" For i = 1 To n.GetUpperBound(0) p(i).Image = New Bitmap("q.jpg") p(i).Enabled = False Next End If End Sub End Class

14 執行圖 記憶時間(以高級的為例)

15 答錯畫面

16 過關畫面

17 時間到~失敗畫面

18 心得 很謝謝謝慶存老師,這2學期教我們電腦程式設計,讓我受益良多,雖然還沒達到隨手就可以寫程式碼的程度,但基本的還是可以看懂,說實在的,我發現我沒有這個方面的特長,所以我做這個作業,還找同學教我,我的愚鈍差點讓他崩潰,我都有點不好意思了,不過在他的指導下,我終於把這個作業做出來了,真的讓我鬆了一口氣,對我來說,打程式碼真的好難阿! 不過還是被我克服了,雖然有點瑕疵,但我想我做這樣應該夠好了,假如還有機會,我會再努力一點的。


Download ppt "計算機程式及實習期末報告 VB 2010設計遊戲程式"

Similar presentations


Ads by Google