Hallo,
da bin ich mal wieder... peinlich peinlich peinlich, aber egal, ihr kennt mich sowieso nicht
Also,
ich habe hier eine Funktion in einer Klasse:
Damit wird, je nach gewünschter Eingabe Blöcke als Picturebox generiert. Das klappt, soweit so gut. Ich kann auch umherlaufen mit den Folgenden Code:
Das klappt auch, soweit so gut.
Die Blöcke werden so abgerufen:
Das klappt auch, soweit so gut. Ich sehe die Blöcke auch auf der Form, soweit so gut.
Doch wie mache ich nun eine Kollisionsabfrage? Ich habe schon folgendes versucht:
das klappt aber nicht, weil er Dirt nicht findet.
Weiß jemand ne Lösung?
da bin ich mal wieder... peinlich peinlich peinlich, aber egal, ihr kennt mich sowieso nicht
Also,
ich habe hier eine Funktion in einer Klasse:
VB.NET-Quellcode
- Public Function generateStone(ByVal anzahl As Integer)
- Dim rnd As New Random
- For i = 0 To anzahl
- Dim BlockType As PictureBox = New PictureBox
- locationX = rnd.Next(1, 42) * 25
- locationY = rnd.Next(1, 31) * 25
- BlockType.Location = New Point(locationX, locationY)
- BlockType.Image = My.Resources.Stein
- BlockType.Width = BlockType.Image.Width
- BlockType.Height = BlockType.Image.Height
- Form1.Controls.Add(BlockType)
- Next i
- Return 0
- End Function
Damit wird, je nach gewünschter Eingabe Blöcke als Picturebox generiert. Das klappt, soweit so gut. Ich kann auch umherlaufen mit den Folgenden Code:
VB.NET-Quellcode
- Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
- If e.KeyCode = Keys.Up Then
- PicturePlayer.Location = New Point(PicturePlayer.Location.X + 0, PicturePlayer.Location.Y - 25)
- End If
- 'Runter
- If e.KeyCode = Keys.Down Then
- PicturePlayer.Location = New Point(PicturePlayer.Location.X + 0, PicturePlayer.Location.Y + 25)
- End If
- 'Rechts
- If e.KeyCode = Keys.Right Then
- PicturePlayer.Location = New Point(PicturePlayer.Location.X + 25, PicturePlayer.Location.Y + 0)
- End If
- 'Links
- If e.KeyCode = Keys.Left Then
- PicturePlayer.Location = New Point(PicturePlayer.Location.X - 25, PicturePlayer.Location.Y + 0)
- End If
- ''Beenden''
- If e.KeyCode = Keys.Escape Then
- Me.Close()
- End If
- End Sub
Das klappt auch, soweit so gut.
Die Blöcke werden so abgerufen:
Das klappt auch, soweit so gut. Ich sehe die Blöcke auch auf der Form, soweit so gut.
Doch wie mache ich nun eine Kollisionsabfrage? Ich habe schon folgendes versucht:
das klappt aber nicht, weil er Dirt nicht findet.
Weiß jemand ne Lösung?