Visual Basic 2008 2D 3D 6-1 6-1 - 6-2 -
06 6-2 STEP 1 5-2 (1) STEP 2 5-3 (2) - 6-3 -
Visual Basic 2008 2D 3D STEP 3 User1 6-4 (3) STEP 4 User1 6-5 (4) - 6-4 -
06 STEP 5 6-6 (5) 6-3 6-3-1 (LoginForm) PictureBox1 txt_username btn_vsman btn_help btn_exit 6-7 Login Form (Login.vb) Public Class Login ' UserName Private Sub btn_vsman_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btn_vsman.click MainForm.UserName = txt_username.text - 6-5 -
Visual Basic 2008 2D 3D MainForm.Label_UserName.Text = txt_username.text MainForm.ShowDialog() ' Private Sub btn_exit_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btn_exit.click Application.Exit() ' Private Sub btn_help_click(byval sender As System.Object, ByVal e As System.EventArgs) Handles btn_help.click MsgBox(" (" "&& vbcrlf & vbcrlf & _ "-------- --------"& vbcrlf & vbcrlf & _ " "& & vbcrlf & vbcrlf & _ " "&& vbcrlf & vbcrlf & _ "@Program Design by Scissor. 2009.03.28", _ MsgBoxStyle.OkOnly + MsgBoxStyle.Question, " ) Private S ub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Class - 6-6 -
06 6-3-2 (MainForm) Label_UserName Label_UserScore Label_UserScoreNum hole1~9 ImageList Timer_game Timer_Thief 6-8 MainForm (Client.vb) Imports System.Text Encode Public Class MainForm #Region Variables Declaration Public UserName As String Private createtime As Integer - 6-7 -
Visual Basic 2008 2D 3D Private usercolor As Color Private score As Integer #End Region #Region Game Functions Private Delegate Sub DelegateInitialize() Public Sub Initialize() score = 0 Label_UserScoreNum.Text = 0 Dim i As Integer For i = 0 To Panel_GameArea.Controls.Count - 1 If Panel_GameArea.Controls (i).name.substring(0, 4) = Hole Then Dim tmppic As PictureBox = Panel_GameArea.Controls(i) tmppic.image = ImageList_Rat.Images.Item(0) tmppic.tag = 0 Next Private Delegate Sub DelegateStartTimer() Private Sub StartTimer() Label_Time.Text = 20 Timer_Game.Enabled = True Timer_Thief.Enabled = True - 6-8 -
06 Private Sub StopTimer() Label_Time.Text = - Timer_Game.Enabled = False Dim i As Integer For i = 0 To Panel_GameArea.Controls.Count - 1 If Panel_GameArea.Controls(i).Name.Substring(0, 4) = Hole Then Dim tmppic As PictureBox = Panel_GameArea.Controls(i) tmppic.image = ImageList_Rat.Images.Item(0) tmppic.tag = 0 Next Private Sub Timer_Game_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer_Game.Tick UpdateRatLiveTime() CreateRandomRat() CheckGame() Private Sub UpdateRatLiveTime() 0 If Integer.Parse(Label_Time.Text) <> 0 Then Dim i As Integer For i = 0 To Panel_GameArea.Controls.Count - 1-6-9 -
Visual Basic 2008 2D 3D If Panel_GameArea.Controls(i).Name.Substring(0, 4) = Hole Then Dim tmppic As PictureBox = Panel_GameArea.Controls(i) If tmppic.tag <> 0 Then tmppic.tag -= 1 Else tmppic.image = ImageList_Rat.Images.Item(0) tmppic.refresh() Next Label_Time.Text = (Integer.Parse(Label_Time.Text) - 1).ToString ElseIf Integer.Parse(Label_Time.Text) = 0 Then StopTimer() Private Sub CreateRat(ByVal CreateName As String) Dim i As Integer For i = 0 To Panel_GameArea.Controls.Count - 1 If Panel_GameArea.Controls(i).Name.Name = CreateName T hen Dim tmppic As PictureBox = Panel_GameArea.Controls(i) tmppic.image = My.Resources.thief_fast tmppic.refresh() tmppic.tag = 2 Exit For Next - 6-10 -
06 Private Sub CreateRandomRat() Dim index As Integer If createtime = 0 Then Randomize() createtime = Rnd() * 5 Else createtime -= 1 If createtime <> 0 Then While True Randomize() index = Rnd() * 8 Dim tmppic As PictureBox = Panel_GameArea.Controls(index) If tmppic.tag = 0 Then tmppic.image = My.Resources.thief_fast tmppic.refresh() tmppic.tag = 2 Exit While End While Private Sub CheckGame() If Integer.Parse(Label_Time.Text) = 0 Then - 6-11 -
Visual Basic 2008 2D 3D StopTimer() MsgBox( ( + score.tostring) Public Sub ratclick(byval sender As Object, ByVal e As System.EventArgs) Handles Hole1. Click, Hole2.Click, _ Hole3.Click, Hole4.Click, Hole5.Click, Hole6.Click, Hole7.Click, Hole8.Click, Hole9.Click Dim tmppic As PictureBox = sender ( ) If tmppic.tag <> 0 Then score += 50 Label_UserScoreNum.Text = score.tostring tmppic.tag = 0 tmppic.image = ImageList_Rat.Images.Item(0) Private Sub EndGame() score = 0 Label_UserScoreNum.Text = 0 StopTimer() #End Region - 6-12 -
06 Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Initialize() StartTimer() Handles MyBase.Load End Class 6-4 - 6-13 -