|
-
May 16th, 2002, 10:35 PM
#1
Thread Starter
Junior Member
Type array
I need to kill enemies in my game. How do I remove them
from a type array?????
my type.....
Code:
type enemy
st as integer
dx as integer
name as string
end type
I have an array of "enemy"
Code:
public uglies() as enemy
uglies(8) dies...
Can I remove uglies(8) without setting all of its elements to empty?????
-
May 17th, 2002, 12:18 AM
#2
PowerPoster
Redim Preserve Whatever( Count )
-
May 17th, 2002, 02:00 AM
#3
Not NoteMe
Originally posted by Fox
Redim Preserve Whatever( Count )
You would first have to shift all the enemies down 1, to make the empty one at the end of the array before you do that, which if you have a lot, could take a while, i suggest just making all it's values null.
When you next create an enemy you could just place him in that space.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 17th, 2002, 04:47 PM
#4
Thread Starter
Junior Member
Thanks but....
Is their a way to set the whole entry to null? Like;
enemy(8) = null
without doing;
enemy(8).st = null
enemy(8).name = ""
etc......
Or do you have to move each one after enemy(8)
down one and redim preserve?
-
May 17th, 2002, 05:01 PM
#5
PowerPoster
nope:
VB Code:
Function DeleteEnemy( Index as Long )
'Move last item
Enemy( Index ) = Enemy( EnemyCount )
'Cut-off last item
EnemyCount = EnemyCount - 1
If EnemyCount < 0 Then
Erase Enemy
Else
Redim Preserve Enemy( EnemyCount )
Endif
End Function
-
May 17th, 2002, 06:13 PM
#6
Thread Starter
Junior Member
Holly crap
that was easy....
why didnt I think of it?
Thanks
-
May 18th, 2002, 04:31 PM
#7
PowerPoster
The easiest things sometimes are the hardest you to work out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|