This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by nickgravelyn

I'm working on a little game and want to have activate-able objects, such as doors and signs, that respond when the user is next to them and presses space bar. The game is a top-down tile based game, if that matters at all.

I currently have all the collisions figured out (i.e. the player can move around but doesn't pass through the activate-able entities), but I'm not sure the right approach with Impact to figure out if I'm next to another entity. I could simply get all the entities, enumerate them, and respond but I'm worried I'll be adding a lot of overhead if my levels start having more than just a few such entities.

Any ideas?

1 decade ago by nickgravelyn

Well for now I've decided to just get the list. I've made a base type I can use for all activateable objects (so I don't enumerate all the entities). So I made "EntitySign" which extends EntityActivateable and gets to add custom logic for an "activate" function that gets called when the player hits space.

Here's a gist of how I'm approaching it: If others have ideas, I'd love to hear them still. :)

1 decade ago by MikeL

I've used a similar technique for my current game. I have bombs that explode. Once they explode I check if the enemy entities are in the vicinity of the bomb blast. I essentially obtain a list as you are doing. It doesn't seem to hold up the game a bit.

One thing that could tighten up your code a bit would be to use the .distanceTo method of Entity, i.e:
if (this.distanceTo( e[i] ) < range){
  //The target is within the right distance so do appropriate stuff.

See the distanceTo method here.
Page 1 of 1
« first « previous next › last »