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

2014/5/12

Trouble using getObjectsInRange

kdbailey kdbailey

2014/5/12

#
I'm having a hero being swarmed by enemies, and to deal damage you need to be facing the enemy (4 images, one for each direction). Basically, if you're facing left and an enemy hits you from behind, but if you are facing the way the enemy hits you then the enemy dies. I'm new to coding and from what it sounds like, this is the command that I want to use. Any help would be appreciated.
danpost danpost

2014/5/12

#
Basically, when being attacked, if their locations are such that they have opposite rotations and are moving toward each other, then the enemy dies; otherwise, the hero dies.
kdbailey kdbailey

2014/5/14

#
danpost wrote...
Basically, when being attacked, if their locations are such that they have opposite rotations and are moving toward each other, then the enemy dies; otherwise, the hero dies.
Thanks a lot, that really cleared things up. Could you give an example on how to set it up for rotations?
danpost danpost

2014/5/14

#
Well, I would presume that an enemy will not attack anything behind it, only in front of it. So when it attacks, if the absolute value of the differences in their rotations is 180 than the enemy dies.
You need to login to post a reply.