1 / 11

南台科技大學 機械工程系 自控一甲 學 號 :4A212006 學生 : 許秉洋 老師 : 謝慶存

計算機 程式及 實習 撲克牌 比 大小. 南台科技大學 機械工程系 自控一甲 學 號 :4A212006 學生 : 許秉洋 老師 : 謝慶存. 目錄. 程式說明 表 單 設計 程式碼 心得. 程式說明. 先按 洗牌 鈕 , 電腦 即亂數 洗牌 , 接著在撲克牌按一下選取, 電腦會自動比較所選的牌是否比未選的牌大 ? 假設撲克牌大小依序 : A<2<3 <…< Q<K: 若所選的牌大,會 顯示 ” 你贏了 ! 按洗牌鈕 重玩 … .” 若所選的牌大小相同,會 顯示 ” 平 手 ! 按洗牌鈕 重玩 … .”

Download Presentation

南台科技大學 機械工程系 自控一甲 學 號 :4A212006 學生 : 許秉洋 老師 : 謝慶存

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. 計算機程式及實習 撲克牌比大小 南台科技大學 機械工程系 自控一甲 學號:4A212006 學生:許秉洋 老師:謝慶存

  2. 目錄 • 程式說明 • 表單設計 • 程式碼 • 心得

  3. 程式說明 先按洗牌鈕,電腦即亂數洗牌,接著在撲克牌按一下選取, 電腦會自動比較所選的牌是否比未選的牌大?假設撲克牌大小依序: A<2<3<…<Q<K: 若所選的牌大,會顯示” 你贏了 ! 按洗牌鈕 重玩 ….” 若所選的牌大小相同,會顯示” 平 手 ! 按洗牌鈕 重玩 ….” 若所選的牌小,會顯示” 你輸了 ! 按洗牌鈕 重玩 ….”

  4. 表單設計 Label PictureBox1 PictureBox2 lblMsg Button2 Button1

  5. 圖檔

  6. 程式碼 Form1 • Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load • pic1.Enabled = False • pic2.Enabled = False • pic1.SizeMode = PictureBoxSizeMode.AutoSize • pic2.SizeMode = PictureBoxSizeMode.AutoSize • pic1.Image = New Bitmap("bk.jpg") • pic2.Image = New Bitmap("bk.jpg") • lblMsg.Text = "按發牌鈕遊戲開始.." • End Sub

  7. PictureBox1 • Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic1.Click • pic1.Image = New Bitmap(“poto” & num1 & “.jpg”) • pic2.Image = New Bitmap(“poto" & num2 & ".jpg") • If num1 > num2 Then • lblMsg.Text = " 你贏了 ! 按發牌鈕 重玩 ...." • Else • If num1 = num2 Then • lblMsg.Text = " 平 手 ! 按發牌鈕 重玩 ...." • Else • lblMsg.Text = " 你輸了 ! 按發牌鈕 重玩 ...." • End If • End If • pic1.Enabled = False • pic2.Enabled = False • Button1.Enabled = True • End Sub

  8. PictureBox2 • Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pic2.Click • pic1.Image = New Bitmap(“poto" & num1 & ".jpg") • pic2.Image = New Bitmap(“poto" & num2 & ".jpg") • If num2 > num1 Then • lblMsg.Text = " 你贏了 ! 按發牌鈕 重玩 ...." • Else • If num2 = num1 Then • lblMsg.Text = " 平 手 ! 按發牌鈕 重玩 ...." • Else • lblMsg.Text = " 你輸了 ! 按發牌鈕 重玩 ...." • End If • End If • pic1.Enabled = False • pic2.Enabled = False • Button1.Enabled = True • End Sub

  9. Button1 • Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click • pic1.Enabled = True • pic2.Enabled = True • Button1.Enabled = False • pic1.Image = New Bitmap("bk.jpg") • pic2.Image = New Bitmap("bk.jpg") • Randomize() • num1 = Int(Rnd() * 13) + 1 • num2 = Int(Rnd() * 13) + 1 • lblMsg.Text = "請在撲克牌上按一下選取 .." • End Sub

  10. 遊戲畫面執行 點選牌面 點選發牌

  11. 心得

More Related