I can't quite figure this out, but any variables within this structure wont take a value; xpos, ypos, and life just remain what they were assigned outside the sub, and wont change inside.
Here's the structure, everything in UpdateShot wont take a value:
Mouse click triggers thsi part:
I have a backgroundworker handle this in another thread:
DoWork
ProgressChanged
Any insight would be greatly appreciated
Here's the structure, everything in UpdateShot wont take a value:
VB.NET:
Public Structure Shot
Dim XPos As Single
Dim YPos As Single
Dim anglex As Single
Dim angley As Single
Dim picbox As PictureBox
Dim speed As Int32
Dim distance As Int32
Dim damage As Int32
Dim life As Int32
Sub UpdateShot()
XPos = XPos + anglex
YPos = YPos + angley
picbox.Location() = New Point(CInt(XPos), CInt(YPos))
life = life + 1
'Add your collision checking code here
End Sub
End Structure
Mouse click triggers thsi part:
VB.NET:
Dim x As New Shot
x.picbox = New PictureBox
x.picbox.Image = pctShot.Image
x.picbox.SizeMode = PictureBoxSizeMode.AutoSize
x.picbox.Location = New Point(myShip.picbox.Location.X + (myShip.picbox.Width / 2), myShip.picbox.Location.Y + (myShip.picbox.Height / 2))
x.XPos = myShip.picbox.Location.X + (myShip.picbox.Width / 2)
x.YPos = myShip.picbox.Location.Y + (myShip.picbox.Height / 2)
x.anglex = -Math.Sin(myShip.angle * Math.PI / 180.0) * 3
x.angley = -Math.Cos(myShip.angle * Math.PI / 180.0) * 3
x.speed = 3
x.distance = 200
x.picbox.Visible = True
Controls.Add(x.picbox)
shotList.Add(x)
I have a backgroundworker handle this in another thread:
DoWork
VB.NET:
For i = 1 To 2
bwShot.ReportProgress(i)
If i = 2 Then i = 1
If bwShot.CancellationPending = True Then
Exit For
End If
System.Threading.Thread.Sleep(50)
Next
ProgressChanged
VB.NET:
Dim y As Shot
For Each y In shotList
If y.life >= y.distance Then
shotList.RemoveAt(shotList.IndexOf(y))
End If
y.UpdateShot()
Label4.Text = y.XPos & " : " & y.YPos
Next
Any insight would be greatly appreciated