iCopter のようなゲームを作ろうとしています。オブジェクトを制御し、動く障害物を通り抜けるように誘導します。
そこで、Fireworks で山だけの単純な png を作成し、それを VB に追加して、オブジェクトが PNG の一部に触れた場合 (Picturebox ではなく、目的が無効になるため)、ゲームを終了するようにしました。
したがって、主な問題は、ピクチャボックスなしで VB に PNG を認識させる方法です (それが可能であれば) ...
ありがとう
背景の動きを継続的に残し、車を動かすことはできますが、衝突を作成したいのですが、内部の実際の画像ではなく、大きなピクチャーボックスの場合と同じように見るのは困難です...
新しいコード/作業
Public Class Form1
Dim upc, leftc, rightc, downc As Boolean
Dim speedofblocks As Integer = 5
Dim speedofguy As Integer = 6
Dim standing As Boolean
Dim blocks(1) As PictureBox
Dim floor(1) As PictureBox
If e.KeyCode = Keys.Left Then
leftc = True
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If e.KeyCode = Keys.Right Then
rightc = True
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If e.KeyCode = Keys.Up Then
upc = True
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If e.KeyCode = Keys.Down Then
downc = True
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If e.KeyCode = Keys.Left Then
leftc = False
End If
If e.KeyCode = Keys.Right Then
rightc = False
End If
If e.KeyCode = Keys.Up Then
upc = False
End If
If e.KeyCode = Keys.Down Then
downc = False
End If
End Sub
PictureBox1.BackgroundImage = My.Resources.GUystand
blocks(1) = PictureBox1
blocks(1) = PictureBox2
blocks(1) = PictureBox3
blocks(1) = PictureBox4
blocks(1) = PictureBox5
blocks(1) = PictureBox6
blocks(1) = PictureBox7
blocks(1) = PictureBox8
blocks(1) = PictureBox3
blocks(1) = PictureBox10
blocks(1) = PictureBox11
blocks(1) = PictureBox12
blocks(1) = PictureBox13
blocks(1) = PictureBox14
blocks(1) = PictureBox15
blocks(1) = PictureBox16
blocks(1) = PictureBox17
blocks(1) = PictureBox18
blocks(1) = PictureBox19
blocks(1) = PictureBox20
blocks(1) = PictureBox21
blocks(1) = PictureBox22
blocks(1) = PictureBox23
blocks(1) = PictureBox24
blocks(1) = PictureBox25
blocks(1) = PictureBox26
blocks(1) = PictureBox27
blocks(1) = PictureBox28
blocks(1) = PictureBox29
blocks(1) = PictureBox30
blocks(1) = PictureBox31
blocks(1) = PictureBox32
blocks(1) = PictureBox33
blocks(1) = PictureBox34
blocks(1) = PictureBox35
blocks(1) = PictureBox36
blocks(1) = PictureBox37
blocks(1) = PictureBox38
blocks(1) = PictureBox39
blocks(1) = PictureBox40
blocks(1) = PictureBox41
blocks(1) = PictureBox42
blocks(1) = PictureBox43
blocks(1) = PictureBox44
blocks(1) = PictureBox45
blocks(1) = PictureBox46
blocks(1) = PictureBox47
blocks(1) = PictureBox48
blocks(1) = PictureBox49
floor(1) = picturebox50
End Sub
If leftc = True Then
PictureBox1.Left -= speedofguy
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If rightc = True Then
PictureBox1.Left += speedofguy
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If upc = True Then
PictureBox1.Top -= speedofguy
PictureBox1.BackgroundImage = My.Resources.guy1
End If
If downc = True Then
PictureBox1.Top += speedofguy
PictureBox1.BackgroundImage = My.Resources.guy1
End If
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox2.Left -= speedofblocks
PictureBox3.Left -= speedofblocks
PictureBox4.Left -= speedofblocks
PictureBox5.Left -= speedofblocks
PictureBox6.Left -= speedofblocks
PictureBox7.Left -= speedofblocks
PictureBox8.Left -= speedofblocks
PictureBox9.Left -= speedofblocks
PictureBox10.Left -= speedofblocks
PictureBox11.Left -= speedofblocks
PictureBox12.Left -= speedofblocks
PictureBox13.Left -= speedofblocks
PictureBox14.Left -= speedofblocks
PictureBox15.Left -= speedofblocks
PictureBox16.Left -= speedofblocks
PictureBox17.Left -= speedofblocks
PictureBox18.Left -= speedofblocks
PictureBox19.Left -= speedofblocks
PictureBox20.Left -= speedofblocks
PictureBox21.Left -= speedofblocks
PictureBox22.Left -= speedofblocks
PictureBox23.Left -= speedofblocks
PictureBox24.Left -= speedofblocks
PictureBox25.Left -= speedofblocks
PictureBox26.Left -= speedofblocks
PictureBox27.Left -= speedofblocks
PictureBox28.Left -= speedofblocks
PictureBox29.Left -= speedofblocks
PictureBox30.Left -= speedofblocks
PictureBox31.Left -= speedofblocks
PictureBox32.Left -= speedofblocks
PictureBox33.Left -= speedofblocks
PictureBox34.Left -= speedofblocks
PictureBox35.Left -= speedofblocks
PictureBox36.Left -= speedofblocks
PictureBox37.Left -= speedofblocks
PictureBox38.Left -= speedofblocks
PictureBox39.Left -= speedofblocks
PictureBox40.Left -= speedofblocks
PictureBox41.Left -= speedofblocks
PictureBox42.Left -= speedofblocks
PictureBox43.Left -= speedofblocks
PictureBox44.Left -= speedofblocks
PictureBox45.Left -= speedofblocks
PictureBox46.Left -= speedofblocks
PictureBox47.Left -= speedofblocks
PictureBox48.Left -= speedofblocks
PictureBox49.Left -= speedofblocks
End Sub
Private Sub Gravity_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gravity.Tick
PictureBox1.Top += 3
For x As Integer = 1 To 49
If PictureBox1.Bounds.IntersectsWith(floor(x).Bounds) And floor(x).Visible = True Then
standing = True
PictureBox1.Top -= 3
End If
If PictureBox1.Bounds.IntersectsWith(blocks(x).Bounds) And blocks(x).Visible = True Then
standing = True
PictureBox1.Top -= 3
End If
Next x
End Sub
配列や Bounds.Intersectswith などを台無しにしたと確信しています。基本的には、基本的な衝突と重力を取得しようとしています。左にスクロールするすべての黒いブロックである一連の画像ボックスを作成し、プレーヤーにそれらを飛び越えさせます。