| View previous topic :: View next topic |
| Author |
Message |
pkyourface Master Cheater
Reputation: 0
Joined: 26 Dec 2006 Posts: 252
|
Posted: Sun Jan 11, 2009 6:41 pm Post subject: [VB6] Array help |
|
|
I have 4 groups of images named Shield1, Shield2, Shield3 and Shield4 and each of those shields has an index of 9 images starting from 0 and ending at 9 so Shield1(0), Shield1(1) and so on.
Using this code: | Code: | For i = 0 To 9
If (Shield1(i).Left + Shield1(i).Width) > Shape1.Left Then
If Shield1(i).Left < (Shape1.Left + Shape1.Width) Then
If (Shield1(i).Top + Shield1(i).Height) > Shape1.Top Then
If Shield1(i).Top < (Shape1.Top + Shape1.Height) Then
collision = True
End If
End If
End If
End If
If collision = True Then
Shape1.Visible = False
collision = False
End If
Next i |
I want that when "i" reaches 9 of the first shield it changes "Shield1" into "Shield2" and then start back from 0 and check for the collision on sheild2 all the way to shield4.
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Sun Jan 11, 2009 7:35 pm Post subject: |
|
|
make at multi dimension array (think thats what its called)
ie
| Code: | For i = 0 To 9
For i2 = 0 To 9
If (Shield(i, i2).Left + Shield1(i, i2).Width) > Shape1.Left Then
If Shield(i, i2).Left < (Shape1.Left + Shape1.Width) Then
If (Shield(i, i2).Top + Shield(i, i2).Height) > Shape1.Top Then
If Shield(i, i2).Top < (Shape1.Top + Shape1.Height) Then
collision = True
End If
End If
End If
End If
If collision = True Then
Shape1.Visible = False
collision = False
End If
Next i
Next i2 |
_________________
|
|
| Back to top |
|
 |
pkyourface Master Cheater
Reputation: 0
Joined: 26 Dec 2006 Posts: 252
|
Posted: Mon Jan 12, 2009 10:58 am Post subject: |
|
|
Thanks a lot, I've never heard of multi dimension arrays but I seems that is what I needed to use and it worked .
|
|
| Back to top |
|
 |
BanMe Master Cheater
Reputation: 0
Joined: 29 Nov 2005 Posts: 375 Location: Farmington NH, USA
|
Posted: Mon Jan 12, 2009 12:04 pm Post subject: |
|
|
| snootae that is pretty interesting solution nice and simple o0
|
|
| Back to top |
|
 |
pkyourface Master Cheater
Reputation: 0
Joined: 26 Dec 2006 Posts: 252
|
Posted: Mon Jan 12, 2009 4:36 pm Post subject: |
|
|
| The multi array works fine but the ".left" at the end makes it say invalid qualifier.. I've resorted to using 4 timers but any other solutions are appreciated.
|
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Jan 14, 2009 7:54 pm Post subject: |
|
|
| Quote: | | The multi array works fine but the ".left" at the end makes it say invalid qualifier.. I've resorted to using 4 timers but any other solutions are appreciated. |
let me see your Dim for the array
it should be | Code: | | Dim Shield(9, 9) As PictureBox | or something, that should work
_________________
|
|
| Back to top |
|
 |
|