私はこのゲームを VB 2010 Express で作成しており、これが初めてのゲームです。そして、キャラクターの家の湖のチェストなどとしてピクチャーボックスを使用しています。そして、私はそれでいくつかの問題を抱えています。そのうちの 1 つは、キャラクター (Picturebox1/myplayer) が胸 (Picturebox2) に触れたときに、胸を開くかそのままにするかを選択できるようにしたことです。チェストを開けることを選択した場合は、10 コインを獲得できます。しかし、チェストを開けて10枚のコインを手に入れたとき、それを使用できないようにすることはできないので、無限にコインを手に入れることができます。
Private Sub mymap_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Dim Loc As Point
Select Case e.KeyCode
Case Keys.W
If Not myplayer.Location.Y - 5 < 0 Then
Loc = New Point(myplayer.Location.X, myplayer.Location.Y - 5)
myplayer.Location = Loc
End If
Case Keys.S
If Not myplayer.Location.Y + 5 < 0 Then
Loc = New Point(myplayer.Location.X, myplayer.Location.Y + 5)
myplayer.Location = Loc
End If
Case Keys.A
If Not myplayer.Location.X - 5 < 0 Then
Loc = New Point(myplayer.Location.X - 5, myplayer.Location.Y)
myplayer.Location = Loc
End If
Case Keys.D
If Not myplayer.Location.X + 5 < 0 Then
Loc = New Point(myplayer.Location.X + 5, myplayer.Location.Y)
myplayer.Location = Loc
End If
End Select
If myplayer.Bounds.IntersectsWith(PictureBox2.Bounds) Then
Chest1.Show()
End If
End Sub
そして、胸を開くかどうかのオプションを開きます。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
MsgBox("You found 10 coins in the chest")
Form1.ProgressBar1.Increment(10)
HouseBuy.ProgressBar1.Increment(10)
HouseSell.ProgressBar1.Increment(10)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Hide()
End Sub
誰でも私を助けることができますか?