This site requires JavaScript, please enable it in your browser!
Greenfoot back
Miikku
Miikku wrote ...

2013/5/28

Ideas to make grenade?

Miikku Miikku

2013/5/28

#
Ideas to make grenade?
A Grenade actor would need several things, a time limit to detonation, a blast radius, and affecting specific actors around it are the three biggest things that come to my mind. A detonation is easy if you know how to create counters that count down or up to the time. The blast radius and affecting other actors is a little bit harder. You need to use getObjectsInRange() to find actors around the grenade, and then affect them accordingly. Here's an example of how to use getObjectsInRange():
private int myRange;
//Other instance variables, constructors, and methods
...

/**
  * @return All the actors around me up to my range
  */
public List<Actors> ActorsAroundMe()
{
    return getObjectsInRange(myRange, Actor.class);
}
...
You need to login to post a reply.