on hit effects

6 views
Skip to first unread message

Jose Martinez

unread,
Jan 2, 2013, 11:42:17 PM1/2/13
to fx-games google group
hello,

One thing that I would like to talk about is the visual effects that appear on an enemy when a shot hits it.

- Should it be the responsibility of the enemy to decide what visual effect to apply?  This may be further enhanced by creating multiple hit-types that the enemy can react differently to... e.g. regular damage or slow down.
- Should it be the responsibility of the bullet?
- Should it be responsibility of the tower?

Also, with regards to the latter two, should it just be a visual effect that appears on top of the enemy or can the visual effect be applied tot he enemy itself, e.g. a tower that freezes change the hue to blue on the enemy. 

Each of these has pros-and cons.  

In my current game it is the responsibility of the the Towers and they apply a hue change on the enemy based on the type of hit... reg-dam (red), slow-down (blue), or radiation (green)... not that I am a fan of this, just detailing one approach.

thanks
jose

Daniel Zwolenski

unread,
Jan 3, 2013, 12:08:29 AM1/3/13
to Jose Martinez, fx-games google group
My gut instinct would have the 'hit' be a joint effort between the Projectile (the thing that does the hitting) and the Enemy (the thing being hit). I don't think the Tower should have much to do with it, it's job is to produce the Projectile - what happens after that is out of its hands really. 

e.g. the BaseProjectile.pulse method would find the Enemies it overlaps with at that time - if it has hit something then it internally calls its own Projectile.hit(Enemy[]). Then each Projectile could implement this differently. 

In the case of a Bullet for example it might do something like: 

hit(Enemy[] e) {
     // just hit the first and then the bullet is done
    e[0].takeDamage(10); 
    this.destroy();
}

In the case of an exploding missile however it might replace itself with an "explosion" (another type of projectile)

hit(Enemy[] e) {
     // hit everyone and then explode
    for each e {e.takeDamage(100)};
    this.destroy();
    level.add(new Explosion(x, y);
}

The Explosion would then go through it's own pulse cycle (maybe getting larger and then smaller). It would have it's own hit implementation that didn't call this.destroy but just took a little bit of damage every pulse that the explosion is active for and for everyone in range. 

A cluster bomb could throw out lots of explosions, etc. 

Then looking at how an enemy reacts to being hit, that can be implemented in the takeDamage method. So a space ship might explode into lots of pieces when it gets hit:

Spaceship.takeDamage() {
    if (lifePoints < 0) {
        Node pieces = buildLotsOfAnimatedPolygons();
        new FadingSpinningTransition(pieces).start();  // this transition would could this.destroy in its onFinished
        setBody(pieces);
    }
}

Whereas a Troll might roar a sound, throw his head back and splatter some blood, etc. 

Troll.takeDamage() {
    playSound(roarSound);
    playThrowHeadBackAndSplatterBloodAnimation();
}

etc, etc. Some Enemies might even shoot back when hit, explode in a ball of flame, or turn around, or speed up, or burst open and turn into lots or nasties, etc. 


The other type of hit though may be something like an affect (i.e. not damage related), where we slow the guy down (freezeEffect) or gradually take damage over time (poisonAffect). In this case I'd see the hit(Enemy) method of the Bullet doing this as well. So maybe something like: 

PoisonDart.hit(Enemy[] e) {
    foreach e {
          e.addAffect(new PoisonAffect(3-points-every-3-seconds).start());
    }
}

The affect would then have its own pulse method (probably triggered through the Enemy's pulse method) that kept applying stuff to the target Enemy periodically, eventually expiring and removing itself. The Enemy could also change it's own visual appearance based on its applied affects (e.g. show with white icicles on it if frozen or show green if poisoned, etc)  This affect stuff probably needs a bit more design work and I'd definitely start without it. 

I feel like this would make for a pretty nice library of things you can build up (e.g. a Tower could shoot missiles, bullets and freeze things just by throwing out different bullets), and Enemies could have different reactions as needed, etc. Gives you a lego box of stuff to assemble into a Level. 

Just my thoughts on it though, totally open to any other ideas. I'm pretty busy for the next while so probably won't be doing any code on this any time soon. 


 


--
 
 

Reply all
Reply to author
Forward
0 new messages