0

私は迷路ゲームを作っていて、ライフを 5 に設定しています。

Dim lives As Integer = 5

フォームのさらに下で、ユーザーが境界に到達すると、ピクチャ ボックスが開始位置に戻り、ライフが 1 つ差し引かれるようにしました。ただし、これは最初の最初のライフが失われた場合を除いてすべて機能し、1 ではなく 2 ライフが減ります。私が使用したコードは次のとおりです。

Private Sub PictureBoxPlayer_move(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBoxPlayer.Move
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall12.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
        End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall11.Bounds) Then
       PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall9.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall8.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall7.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall6.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall5.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall4.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall3.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall2.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    If PictureBoxPlayer.Bounds.IntersectsWith(PictureBoxWall1.Bounds) Then
        PictureBoxPlayer.Location = New Point(44, 503)
        lives -= 1
        LabelLives.Text = lives
    End If
    End Sub

私は何が間違っているのでしょうか?

4

0 に答える 0