Jump to content

Creating an entity for a bird snare


iponu777

Recommended Posts


// 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
Link to comment
Share on other sites

// 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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