jeudi 18 mai 2023

picture boxes random location and collision like on vb

I'm making a game for my class and it's like a little maze. One on the forms asks for it to have random PictureBoxes around the screen and if you touch them then you die and the program ends. With the random component I used,

Dim random As New Random
Dim newLeft As Integer = Panel.Width * Rnd()
Dim newTop As Integer = Panel.Height * Rnd()

PictureBox2.Left = newLeft
PictureBox2.Top = newTop

PictureBox4.Left = newLeft
PictureBox4.Top = newTop

and the Panel.Height and Panel.Width are underlined with red. When I click on them they say

"BC30469 Reference to a non-shared member requires an object reference"

I need some help with the PictureBoxes touching first then them having random locations but within the form.

I have tried many different codes for both but nothing has worked and the panel code for BC30469 still says the same thing.




Aucun commentaire:

Enregistrer un commentaire