While trying to make attacks for an autoghosted boss, I found out the way to make many good things, but one is befuddling me to no extent.
I'd like the boss to shoot the projectiles in different directions not straight, rather in a curved path, like here:
http://www.shutterst...nline=256440580
I thought this would do it:
fireball[0] = FireEWeapon(ghost->Weapon, ghost->X, ghost->Y, 45, 10, ghost->WeaponDamage, SPRITE_BALL_ENERGY2, 0, EWF_UNBLOCKABLE); fireball[1] = FireEWeapon(ghost->Weapon, ghost->X, ghost->Y, 135, 10, ghost->WeaponDamage, SPRITE_BALL_ENERGY2, 0, EWF_UNBLOCKABLE); fireball[2] = FireEWeapon(ghost->Weapon, ghost->X, ghost->Y, 225, 10, ghost->WeaponDamage, SPRITE_BALL_ENERGY2, 0, EWF_UNBLOCKABLE); fireball[3] = FireEWeapon(ghost->Weapon, ghost->X, ghost->Y, 315, 10, ghost->WeaponDamage, SPRITE_BALL_ENERGY2, 0, EWF_UNBLOCKABLE); SetEWeaponMovement(fireball[0], EWM_SINE_WAVE, 80, 120); SetEWeaponMovement(fireball[1], EWM_SINE_WAVE, 80, 120); SetEWeaponMovement(fireball[2], EWM_SINE_WAVE, 80, 120); SetEWeaponMovement(fireball[3], EWM_SINE_WAVE, 80, 120);
Since 10 amplitude and 10 frequency made the projectiles resonate a bit and move very slow (fun, and plausible with limited projectile time, but is not what I'm looking for here), I thought an amplitude of 80 would make the curve return to the x axis after 80 pixels after a 120 pixels of deviation at its tangent mean. INSTEAD the same vibration happened, except now the projectiles also kept vanishing each 2nd frame. WHAT?!
I also was trying the "drift" movement, but it made just one sprite instead of 4 and made it thunder through the screen from left to right (even though the startpoint is clearly the boss...). Acceleration type was made it just flash up here and there on the screen almost randomly. It's true I accidentally had 0 as step speed in both cases.
So, how to make that curved path?
I know the enemy of the week entry, Daygleam (from where I copy kinda all my projectile shooting code lines) has it right, but there the path is drawn by creating a new eweapon at each pixel of the curved path... I want one single eweapon to travel through that curved path.
Now...
I generally know what trigonometry is...
Sinus is wavy, cosinus is wavy pushed a bit away, tangent is the this: |- and produces a strange matrix.
But I just can't know and absolutely don't see where to use which. WHY is it that when drawing something around a target in a circle, the X coordinate has a sinus-ed value added, while the Y has cosinus-ed one added.
Is there a place from where I could learn these ZC relations? For example "To have something keep circling the target, add x-cos(x) to the x and y-tangent(y)*0.06+56.386 every frame. The mathematical explanation is..."