Development Blog‎ > ‎

The four Astra swords

posted Dec 29, 2011, 1:24 PM by Mavrik Games
The four Astra swords are a lot like the four elemental swords in Crystalis. The player can swing them around like normal swords, but they can also be "charged" with Astra, and when you release the charges, you get different effects. Like Crystalis, there are three levels of charges, but unlike Crystalis, they're not all projectiles. The first level is still hand-to-hand. It targets one enemy and causes an effect on that enemy. For example, the fire Astra sword will set the enemy on fire doing damage over time. The second level effect is a projectile that causes the same effect, but affects enemies within a radius of the impact. The third level causes a wide area effect centered on the player.

When I started building the AstraSword class, I didn't want to make a class for each sword because I would end up repeating a lot of code. I also couldn't in good conscious put all the effects in one class and simply activate the effect I wanted (shudder). To get around this issue, I set up a framework where an Archetype can be created for each Astra sword and a DamageType is assigned through the Archetype. That way, I only have to create one AstraSword class and just call its DamageType's functions when I need them. I created an abstract class that inherited from DamageType and a subclass for each sword. Each AstraDamageType has a function for a level one, level two, and level three effect, and I can define what those effects are individually.

Another issue I ran into was with the animations. I had set up different states for the different attack modes for the sword, and I wanted the player's animations to play accordingly. I tried syncing the fire intervals with the lengths of the animations, but it was glitchy. Instead, I decided to set up all my animations to be one second long and I would use the PlayCustomAnimByDuration function and force the animations to play in the amount of time given by the fire intervals. This opened up the ability to adjust the animation speeds for each sword individually, as the fire intervals are available to the Archetype. So now I can use the same animations no matter which sword the player has equiped, but I can make the wind Astra sword swing faster than say the ice Astra sword.