掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
画像の周囲に残像が残る (ID:142738)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
稚拙なボウリングゲームのコードです。 2つのレーンがあり、2人で対戦することもできます。 また、自分の写真を読み込むことやピンが倒れたときの カキーンという効果音やストライクのときには歓声を挿入しました。 Dim x, y As Integer Dim flag As Boolean = True Dim kekka As Integer'結果パターン1(倒れたピンと立っているピンの数) Dim kekka2 As Integer’ Dim kekka3 As Integer Dim kekka4 As Integer Dim kekka5 As Integer Dim kekka6 As Integer Dim kekka7 As Integer Dim kekka8 As Integer Dim kekka9 As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label15.Text = "" End Sub ’ストライクがでたらミュージックが流れる Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer Dim SoundFileName As String Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim g As Graphics g = PictureBox1.CreateGraphics() If PictureBox1.Left > 0 Then PictureBox1.Left = PictureBox1.Left - 8 End If ’玉をころがす flag = Not flag If flag = True Then g.DrawImage(PBa.Image, x, y, PictureBox1.Width, PictureBox1.Height) Else g.DrawImage(PBb.Image, x, y, PictureBox1.Width, PictureBox1.Height) End If Randomize() kekka4 = Int(6 * Rnd() + 1) If PictureBox1.Left < 320 Then PictureBox1.Left = PictureBox1.Left - 5 Select Case kekka Case 0 PB10.Visible = False '立っているピンの画像(PB○) PB10a.Visible = True '倒れているピンの画像(PB○a) PB9.Visible = False PB9a.Visible = True PB8.Visible = False PB8a.Visible = True Case 1 PB7.Visible = False PB7a.Visible = True PB6.Visible = False PB6a.Visible = True PB5.Visible = False PB5a.Visible = True PB4.Visible = False PB4a.Visible = True Case 2 PB3.Visible = False PB3a.Visible = True PB3.Visible = False PB2a.Visible = True PB2.Visible = False PB1a.Visible = True PB1.Visible = False End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If If PictureBox1.Left <= 320 Then PictureBox1.Left = PictureBox1.Left - 5 Select Case kekka Case 0 PB10.Visible = False PB10a.Visible = True Case 1 PB9.Visible = False PB9a.Visible = True Case 2 PB8.Visible = False PB8a.Visible = True Case 3 PB10.Visible = False PB10a.Visible = True PB9.Visible = False PB9a.Visible = True PB8.Visible = False PB8a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If kekka2 = Int(10 * Rnd() + 1) If PictureBox1.Left <= 240 Then PictureBox1.Left = PictureBox1.Left - 5 Select Case kekka2 Case 0 PB5.Visible = False PB5a.Visible = True Case 1 PB6.Visible = False PB6a.Visible = True Case 2 PB7.Visible = False PB7a.Visible = True Case 3 PB5.Visible = False PB5a.Visible = True PB6.Visible = False PB6a.Visible = True PB7.Visible = False PB7a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If If PictureBox1.Left <= 160 Then PictureBox1.Left = PictureBox1.Left - 5 kekka3 = Int(8 * Rnd() + 1) Select Case kekka3 Case 0 PB1.Visible = False PB1a.Visible = True Case 1 PB2.Visible = False PB2a.Visible = True Case 2 PB3.Visible = False PB3a.Visible = True Case 3 PB1.Visible = False PB1a.Visible = True PB2.Visible = False PB2a.Visible = True PB3.Visible = False PB3a.Visible = True PB4.Visible = False PB4a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If If PictureBox1.Left <= 20 Then PictureBox1.Left = 20 flag = False Timer1.Enabled = False End If If PB10a.Visible And PB9a.Visible And PB8a.Visible And PB7a.Visible And PB6a.Visible And PB5a.Visible _ And PB4a.Visible And PB3a.Visible And PB2a.Visible And PB1a.Visible = True Then SoundFileName = """app.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) PictureBox6.Visible = True End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Button6.Visible = False Button7.Visible = False Timer1.Enabled = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click PictureBox6.Visible = False TextBox1.Text = "" TextBox23.Text = "" If PictureBox1.Left <= 20 Then PictureBox1.Left = 688 End If PB1.Visible = True PB2.Visible = True PB3.Visible = True PB4.Visible = True PB5.Visible = True PB6.Visible = True PB7.Visible = True PB8.Visible = True PB9.Visible = True PB10.Visible = True PB1a.Visible = False PB2a.Visible = False PB3a.Visible = False PB4a.Visible = False PB5a.Visible = False PB6a.Visible = False PB7a.Visible = False PB8a.Visible = False PB9a.Visible = False PB10a.Visible = False Label15.Text = Label15.Text & TextBox16.Text & vbLf TextBox16.Text = Nothing End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim g As Graphics g = PictureBox3.CreateGraphics() If PictureBox3.Left > 0 Then PictureBox3.Left = PictureBox3.Left - 8 End If flag = Not flag If flag = True Then g.DrawImage(PBa.Image, x, y, PictureBox1.Width, PictureBox1.Height) Else g.DrawImage(PBb.Image, x, y, PictureBox1.Width, PictureBox1.Height) End If Randomize() kekka5 = Int(7 * Rnd() + 1) If PictureBox3.Left < 288 Then PictureBox3.Left = PictureBox3.Left - 5 Select Case kekka5 Case 0 PBz10.Visible = False PBz10a.Visible = True PBz8.Visible = False PBz8a.Visible = True Case 1 PBz7.Visible = False PBz7a.Visible = True PBz6.Visible = False PBz6a.Visible = True PBz4.Visible = False PBz4a.Visible = True Case 2 PBz3.Visible = False PBz3a.Visible = True PBz3.Visible = False PBz2a.Visible = True PBz2.Visible = False End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If kekka6 = Int(6 * Rnd() + 1) If PictureBox3.Left < 288 Then PictureBox3.Left = PictureBox3.Left - 5 Select Case kekka6 Case 0 PBz10.Visible = False PBz10a.Visible = True Case 1 PBz9.Visible = False PBz9a.Visible = True PBz10.Visible = False PBz10a.Visible = True Case 2 PBz8.Visible = False PBz8a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If kekka7 = Int(6 * Rnd() + 1) If PictureBox3.Left <= 208 Then PictureBox3.Left = PictureBox3.Left - 5 Select Case kekka7 Case 0 PBz7.Visible = False PBz7a.Visible = True Case 1 PBz6.Visible = False PBz6a.Visible = True Case 2 PBz5.Visible = False PBz5a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If kekka8 = Int(6 * Rnd() + 1) If PictureBox3.Left <= 240 Then PictureBox3.Left = PictureBox3.Left - 8 Select Case kekka8 Case 0 PBz3.Visible = False PBz3a.Visible = True Case 1 PBz2.Visible = False PBz2a.Visible = True PBz1.Visible = False PBz1a.Visible = True Case 2 PBz3.Visible = False PBz3a.Visible = True Case 3 PBz2.Visible = False PBz2a.Visible = True PBz3.Visible = False PBz3a.Visible = True PBz4.Visible = False PBz4a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If If PictureBox3.Left <= 168 Then PictureBox3.Left = PictureBox3.Left - 8 kekka9 = Int(8 * Rnd() + 1) Select Case kekka9 Case 0 PBz1.Visible = False PBz1a.Visible = True PBz3.Visible = False PBz3a.Visible = True Case 1 PBz2.Visible = False PBz1.Visible = False PBz1a.Visible = True PBz2a.Visible = True Case 2 PBz3.Visible = False PBz3a.Visible = True PBz1.Visible = False PBz1a.Visible = True Case 3 PBz1.Visible = False PBz1a.Visible = True PBz2.Visible = False PBz2a.Visible = True PBz3.Visible = False PBz3a.Visible = True End Select SoundFileName = """metal.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) End If If PictureBox3.Left <= 20 Then PictureBox3.Left = 20 flag = False Timer2.Enabled = False End If If PBz10a.Visible And PBz9a.Visible And PBz8a.Visible And PBz7a.Visible And PBz6a.Visible And PBz5a.Visible _ And PBz4a.Visible And PBz3a.Visible And PBz2a.Visible And PBz1a.Visible = True Then SoundFileName = """app.wav""" mciSendString("Play " & SoundFileName, vbNull, 0, 0) PictureBox7.Visible = True End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Timer2.Enabled = True Button6.Visible = False Button7.Visible = False End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click PictureBox7.Visible = False TextBox1.Text = "" TextBox24.Text = "" If PictureBox3.Left <= 20 Then PictureBox3.Left = 688 End If PBz1.Visible = True PBz2.Visible = True PBz3.Visible = True PBz4.Visible = True PBz5.Visible = True PBz6.Visible = True PBz7.Visible = True PBz8.Visible = True PBz9.Visible = True PBz10.Visible = True PBz1a.Visible = False PBz2a.Visible = False PBz3a.Visible = False PBz4a.Visible = False PBz5a.Visible = False PBz6a.Visible = False PBz7a.Visible = False PBz8a.Visible = False PBz9a.Visible = False PBz10a.Visible = False End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Label15.Text = Nothing End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click If OpenFileDialog1.ShowDialog() = DialogResult.Cancel Then Exit Sub End If PictureBox2.Image = Image.FromFile(OpenFileDialog1.FileName) End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If OpenFileDialog2.ShowDialog() = DialogResult.Cancel Then Exit Sub End If PictureBox4.Image = Image.FromFile(OpenFileDialog2.FileName) End Sub End Class
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.