Results 1 to 7 of 7

Thread: Type array

  1. #1

    Thread Starter
    Junior Member Ruskin's Avatar
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    18

    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?????

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Redim Preserve Whatever( Count )

  3. #3
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    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.


  4. #4

    Thread Starter
    Junior Member Ruskin's Avatar
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    18
    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?

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    nope:

    VB Code:
    1. Function DeleteEnemy( Index as Long )
    2.    'Move last item
    3.    Enemy( Index ) = Enemy( EnemyCount )
    4.    
    5.    'Cut-off last item
    6.    EnemyCount = EnemyCount - 1
    7.    If EnemyCount < 0 Then
    8.       Erase Enemy
    9.    Else
    10.       Redim Preserve Enemy( EnemyCount )
    11.    Endif
    12. End Function

  6. #6

    Thread Starter
    Junior Member Ruskin's Avatar
    Join Date
    Jan 2002
    Location
    Michigan
    Posts
    18

    Post

    Holly crap
    that was easy....
    why didnt I think of it?

    Thanks

  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    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
  •  



Click Here to Expand Forum to Full Width