タイトル | : ぼくちんも作りました。モグラです |
記事No | : 8501 |
投稿日 | : 2008/12/28(Sun) 18:43 |
投稿者 | : ローマ皇帝レオ♪ |
若葉マークのレオ♪です(8ヶ月) もぐらタタキ.reoオリジナル Option Strict On 'vista 'VisualBasic2008 Public Class form1 Private p_Box_Suu As Integer = 8 'PictureBox数 Private p_Box(p_Box_Suu - 1) As PictureBox Private mogura_p_suu As Integer = 10 'もぐらキャラ数 Private mogura(mogura_p_suu - 1) As Image Private mog_jyoutai(p_Box_Suu - 1) As Integer '各PictureBoxのもぐら状態 Private end_count As Integer = 0 'もぐら出現カウント Private score As Integer = 0 '得点 Private level As Integer = 0
Public Sub New() ' この呼び出しは、Windows フォーム デザイナで必要です。 InitializeComponent() ' InitializeComponent() 呼び出しの後で初期化を追加します。 mogura(0) = My.Resources.mogu0 mogura(1) = My.Resources.mogu5 mogura(2) = My.Resources.mogu4 mogura(3) = My.Resources.mogu3 mogura(4) = My.Resources.mogu2 mogura(5) = My.Resources.mogu1 mogura(6) = My.Resources.mogu2 mogura(7) = My.Resources.mogu3 mogura(8) = My.Resources.mogu4 mogura(9) = My.Resources.mogu5 End Sub Private Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load p_Box(0) = PictureBox1 p_Box(1) = PictureBox2 p_Box(2) = PictureBox3 p_Box(3) = PictureBox4 p_Box(4) = PictureBox5 p_Box(5) = PictureBox6 p_Box(6) = PictureBox7 p_Box(7) = PictureBox8 'もぐら状態の初期化 syokika() End Sub Private Sub syokika() For i As Integer = 0 To p_Box_Suu - 1 mog_jyoutai(i) = 0 Next For i As Integer = 0 To p_Box_Suu - 1 p_Box(i).Image = mogura(0) Next end_count = 0 Label2.Text = score.ToString Label4.Text = level.ToString StartButton.Visible = True レベルButton.Visible = True End Sub
Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click score = 0 syokika() StartButton.Visible = False レベルButton.Visible = False Timer1.Interval = 100 Timer1.Start() レベルTimer.Interval = 1500 - level * 200 レベルTimer.Start() End Sub Private Sub レベルButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles レベルButton.Click level += 1 If level = 4 Then level = 0 Label4.Text = level.ToString End Sub Private Sub mogura_deta(ByVal p_Number As Integer) Dim mog_deru As Integer mog_deru = mog_jyoutai(p_Number) p_Box(p_Number).Image = mogura(mog_deru) mog_deru += 1 If mog_deru = 10 Then mog_deru = 0 End If mog_jyoutai(p_Number) = mog_deru End Sub Private Sub mogura_deru_ramdom() Dim rand As System.Random Dim i As Integer rand = New System.Random() i = rand.Next(p_Box_Suu) mog_jyoutai(i) = 1 end_count += 1 If end_count = 11 Then ending() End If End Sub Private Sub ending() Me.Timer1.Stop() Me.レベルTimer.Stop() syokika() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick For i As Integer = 0 To p_Box_Suu - 1 If mog_jyoutai(i) > 0 Then mogura_deta(i) Else p_Box(i).Image = mogura(0) End If Next End Sub
Private Sub レベルTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles レベルTimer.Tick mogura_deru_ramdom() End Sub
Private Sub push_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click, PictureBox8.Click, PictureBox7.Click, PictureBox6.Click, PictureBox5.Click, PictureBox4.Click, PictureBox3.Click, PictureBox2.Click Dim click As Windows.Forms.PictureBox = DirectCast(sender, Windows.Forms.PictureBox) Dim kensa As Integer kensa = CInt(click.Tag) If mog_jyoutai(kensa) > 0 Then score += 10 + level * 2 mog_jyoutai(kensa) = 0 End If Label2.Text = score.ToString End Sub End Class
|