Jump to content

Creating an entity for a bird snare


Recommended Posts

Posted (edited)


// Define this as a field, not local var!

ArrayList<Position> mySnares = new ArrayList<Position>();

 

// Run this when you want to add a Position

mySnares.add(theSnareEntity.getPosition());

 

// Run this when you want to retrieve a snare via its Position

Entity mySnare = getObjects().closest(new NameFilter("Snare"), new PositionFilter(mySnares.get(snareIndex));

mySnares.remove(snareIndex);

mySnare.interact("Pickup");

Edited by dudeami
Posted
// Define this as a field, not local var!
ArrayList<Position> mySnares = new ArrayList<Position>();
 
// Run this when you want to add a Position
mySnares.add(theSnareEntity.getPosition());
 
// Run this when you want to retrieve a snare via its Position
Entity mySnare = getObjects().closest(new NameFilter("Snare"), new PositionFilter(mySnares.get(snareIndex));
mySnares.remove(snareIndex);
mySnare.interact("Pickup");

linked lists are usually better performance when doing a lot of adding/removing from the lists

  • Like 1
Posted (edited)

Not something to worry about at this level tongue.png

I understand lists and stuff, just not the syntax or stuff like filters and some other stuff... my knowledge is limited to AP CS teachings,. Where just learning really about polymorphism, inheritance, and stuff like that for sub and super classes atm

Edited by iponu777

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...