Impact

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

1 decade ago by cikaslicc

Think of a "Wack a Mole" game, but instead of entities popping from a hole, they would be coming from for different sides. Basically, there's an entity in the middle that you're trying to protect, and these four different entities are coming from four different sides, trying to take it away.

When you click on each one, it retracts back, and so on, repeating for 30 seconds.

How would I randomize these four entities with pos.x and pos.y movements? So. one comes at it, I click it retracts, etc.

I'm pretty new at this, so any help is appreciated.

1 decade ago by stahlmanDesign

in Entity update method something like this:

var r = Math.random()

if (r<0.01 && !this.attacking)doAttack(); 
// 1% of the time he will attack if not already attacking.
// But this is quite often because it's in the update loop which is 60fps.


Once your attack is triggered you can do another random check to determine from which direction the attack comes.
Page 1 of 1
« first « previous next › last »