開啟檔案

advertisement
程式設計-期末專題企劃書
『OOXX』
學校:南台科技大學
指導老師:王博文
日期:2013/6/17
組別
四
學號
姓名
4A190017
陳佳伶
4A190039
丁亦汶
一、 程式簡介
1). 動機
由於我們小時候常常無聊就拿一張紙在那邊到處亂找人說你要不
要跟我玩圈圈叉叉,覺得圈圈叉叉好玩又有挑戰性,所以我們就想說利
用程式做做看。
2). 特色
由於程式的風格較為簡單,我們讓玩家可以依據自己喜歡的顏色選
擇背景,然後我們用了皮卡丘跟綠水靈作為代表。讓我們的程式更增加
了童年的回憶。
二、 程式設計
1.一執行跑馬燈會跑
2.選擇背景
3.下 START 遊戲即將開始
4.皮卡丘(O)綠水靈(X)開始遊戲
5.皮卡丘(O)獲勝
6.綠水靈(X)獲勝
7.雙方平手
三、 程式馬
Public Class Form1
Dim time As Integer = 1, Lattice(10) As Integer /time 為一次遊戲點擊最大次數與辨認由哪
方點擊
lattice 辨認是不是已點擊
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click/如果點擊開始
Panel1.Visible = True
Panel2.Visible = True
Button1.Visible = False/隱藏開始
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label1.Click
If time Mod 2 = 1 And Lattice(1) = 0 Then/辨認是否點擊過與由哪方點擊
Label1.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(1) = 0 Then
Label1.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(1) = time Mod 2 + 1/辨認是否點擊過與由哪方點擊
time = time + 1 /換對方點擊
check(1) /檢查圈圈方是不是勝利
check(2) /檢查叉叉方是不是勝利
每次都檢查是因為不知道此次是由哪方下手
以下
Label1~9皆一樣
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label2.Click
If time Mod 2 = 1 And Lattice(2) = 0 Then
Label2.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(2) = 0 Then
Label2.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(2) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label3.Click
If time Mod 2 = 1 And Lattice(3) = 0 Then
Label3.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(3) = 0 Then
Label3.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(3) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label4.Click
If time Mod 2 = 1 And Lattice(4) = 0 Then
Label4.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(4) = 0 Then
Label4.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(4) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label5.Click
If time Mod 2 = 1 And Lattice(5) = 0 Then
Label5.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(5) = 0 Then
Label5.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(5) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label6.Click
If time Mod 2 = 1 And Lattice(6) = 0 Then
Label6.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(6) = 0 Then
Label6.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(6) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label7.Click
If time Mod 2 = 1 And Lattice(7) = 0 Then
Label7.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(7) = 0 Then
Label7.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(7) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label8.Click
If time Mod 2 = 1 And Lattice(8) = 0 Then
Label8.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(8) = 0 Then
Label8.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(8) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Label9.Click
If time Mod 2 = 1 And Lattice(9) = 0 Then
Label9.Image = WindowsApplication1.My.Resources.Resources.OO
PictureBox3.Visible = False
PictureBox4.Visible = True
ElseIf time Mod 2 = 0 And Lattice(9) = 0 Then
Label9.Image = WindowsApplication1.My.Resources.Resources.XX
PictureBox3.Visible = True
PictureBox4.Visible = False
End If
Lattice(9) = time Mod 2 + 1
time = time + 1
check(1)
check(2)
End Sub
Sub ed()
For j = 1 To 9
Lattice(j) = 3
Next
End Sub
Sub check(ByVal i) /土法煉鋼一個一個檢查,以字串方式檢查哪一個自己有按過,是否連線
Dim S As String
For j = 1 To 9
If Lattice(j) = i Then
S = S & j
End If
Next
If InStr(S, "1") > 0 Then
If InStr(S, "2") > 0 Then
If InStr(S, "3") > 0 Then
Button2.Visible = True
ed()
End If
End If
If InStr(S, "5") > 0 Then
If InStr(S, "9") > 0 Then
Button2.Visible = True
ed()
End If
End If
If InStr(S, "4") > 0 Then
If InStr(S, "7") Then
Button2.Visible = True
ed()
End If
End If
ElseIf InStr(S, "2") > 0 Then
If InStr(S, "5") > 0 Then
If InStr(S, "8") > 0 Then
Button2.Visible = True
ed()
End If
End If
ElseIf InStr(S, "3") > 0 Then
If InStr(S, "6") > 0 Then
If InStr(S, "9") > 0 Then
Button2.Visible = True
ed()
End If
End If
If InStr(S, "5") > 0 Then
If InStr(S, "7") Then
Button2.Visible = True
ed()
End If
End If
ElseIf InStr(S, "4") > 0 Then
If InStr(S, "5") Then
If InStr(S, "6") Then
Button2.Visible = True
ed()
End If
End If
ElseIf InStr(S, "7") Then
If InStr(S, "8") Then
If InStr(S, "9") Then
Button2.Visible = True
ed()
End If
End If
End If
If Lattice(1) = 3 And i = 2 Then
PictureBox5.Image = WindowsApplication1.My.Resources.Resources.loser2
PictureBox5.Visible = True
Lattice(1) = 4
My.Computer.Audio.Stop()/音樂停止
My.Computer.Audio.Play("C:\Users\user\Downloads\OOXX\OOXX\1.wav",
AudioPlayMode.BackgroundLoop) /贏方出現聲音
ElseIf Lattice(1) = 3 And i = 1 Then
PictureBox5.Image = WindowsApplication1.My.Resources.Resources.loser
PictureBox5.Visible = True
Lattice(1) = 4
My.Computer.Audio.Stop()
My.Computer.Audio.Play("C:\Users\user\Downloads\OOXX\OOXX\bubbs.wav",
AudioPlayMode.BackgroundLoop)
End If
If i = 2 And time = 10 And Lattice(1) < 3 Then
Button2.Visible = True
ed()
PictureBox5.Image = WindowsApplication1.My.Resources.Resources.tie
PictureBox5.Visible = True
Lattice(1) = 4
My.Computer.Audio.Stop()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click /點擊此鍵全部重置 一切圖案皆以背景更換
Label1.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label2.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label3.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label4.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label5.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label6.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label7.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label8.Image = WindowsApplication1.My.Resources.Resources.backcolor
Label9.Image = WindowsApplication1.My.Resources.Resources.backcolor
PictureBox3.Visible = True
PictureBox4.Visible = False
PictureBox5.Visible = False
Button2.Visible = False
time = 1
My.Computer.Audio.Play("C:\Users\user\Downloads\OOXX\OOXX\神奇寶貝剪好鈴聲.wav",
AudioPlayMode.BackgroundLoop)
For i = 1 To 9
Lattice(i) = 0
Next
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
My.Computer.Audio.Play("C:\Users\user\Downloads\OOXX\OOXX\神奇寶貝剪好鈴聲.wav",
AudioPlayMode.BackgroundLoop) /一直行將出現音效
End Sub
Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolStripItemClickedEventArgs)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Timer1.Tick
PictureBox6.Left = PictureBox6.Left - 200
If PictureBox6.Right < 0 Then PictureBox6.Left = Me.ClientSize.Width
End Sub
Private Sub 綠ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles 綠ToolStripMenuItem.Click
Me.BackgroundImage = New
Bitmap("C:\Users\user\Downloads\OOXX\OOXX\images\1212.jpg")
End Sub
Private Sub 灰ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles 灰ToolStripMenuItem.Click
Me.BackgroundImage = New
Bitmap("C:\Users\user\Downloads\OOXX\OOXX\images\1313.jpg")
End Sub
Private Sub 粉紅ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles 粉紅ToolStripMenuItem.Click
Me.BackgroundImage = New
Bitmap("C:\Users\user\Downloads\OOXX\OOXX\images\1414.jpg")
End Sub
Private Sub 藍ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles 藍ToolStripMenuItem.Click
Me.BackgroundImage = New
Bitmap("C:\Users\user\Downloads\OOXX\OOXX\images\1515.jpg")
End Sub
End Class
Download