Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Megaman - Cutman Weapon

This thread is locked; no one can reply to it. rss feed Print
Megaman - Cutman Weapon
killocan
Member #1,556
October 2001
avatar

Hey!

So, i'm creating a megaman clone, and now it's time to create the weapon from cutman, supper cutter. For reference, here a example of it being used in several cases:

VIDEO (YOUTUBE)

It's worth to notice that in the "going" path it is a very simple and always equal parabolic path, the thing is while it is returning. If megaman run towards or away from it or if megaman change its Y position, the weapon follows, but without affecting the weapon X velocity much or creating strange movements. I've tried using polar coordinates to simulate an ellipse but the result is not that close, i also tried to "seek" megaman while the weapon is returning using something close to Amarillion's tutorial: <a href="http://www.helixsoft.nl/articles/circle/sincos.htm" SINCOS </a> But it's not the same either. The closest i got was using splines and some cosine interpolation all together, but that's overkill, i guess. So how would you implement this weapon behavior?

Thanks!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Audric
Member #907
January 2001

For the first half or 3/4 of animation, I would use a pre-set trajectory that completely ignores the players' original velocity and current position.
For the last part, I would use more and more of the player's current position, as a "sliding average".
For example if there are 30 frames to perform the last part of the pre-set trajectory (at 60FPS, this would be half a second) :
Original position when shooting is original_x, original_y
Compute delta_x = current_x - original_x
Compute delta_y = current_y - original_y
Having current_frame ranging from 0 to 30,
Compute arc_x, arcy as a theorical arc that doesn't track the player (it started at original_x, original_y)
Adjusted position is
arc_x * (30-current_frame) / 30 + (arc_x + delta_x) * (current_frame) / 30
arc_y * (30-current_frame) / 30 + (arc_y + delta_y) * (current_frame) / 30)

No matter how fast the player is moving in any direction, the last frame will be exactly on him.

edit: fixed formula, hopefully.
edit2: It's actually clearer if the arc variables are starting and ending at (0,0), because you can skip the computation of delta, and do directly :
arc_x + (original_x * (30-current_frame) + current_x * current_frame) / 30
arc_y + (original_y * (30-current_frame) + current_y * current_frame) / 30

Mark Oates
Member #1,146
March 2001
avatar

What happens if he dies in the middle of the arc?

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

killocan
Member #1,556
October 2001
avatar

Is the cutter's position relative to megaman?

Yes, it is. But a 'regular' ellipse do not behave like the cutter, as mentioned for the first half and so of the trajectory it ignores megaman current position, after that, it tracks him down, without losing all of its original trajectory, i.e, if you just fire and stay still the cutter do a full ellipse, otherwise it follows megaman.

What happens if he dies in the middle of the arc?

I tested it, the cutter "let it go" of following its original path and just fly "right" in an straight "line".

Audric said:

For the first half or 3/4 of animation, I would use a pre-set trajectory that completely ignores the players' original velocity and current position.
For the last part, I would use more and more of the player's current position, as a "sliding average".

Interesting approach, as i said before, i used a mix of spline and interpolation to solve this, and i did notice that for 3/4 of the animation, the cutter dont bother about megaman pos, so i fixed the path using a spline, after that i update using a interpolation between its current position and megaman's. But the result although very close is not "a match", will try yours, seems legit, thanks for the clue. One (two?) question:

1- edited: i get it hehehe
2- original_x is the start position of the fire and current(x,y) is megaman's position, right?

\o

Audric
Member #907
January 2001

I didn't think so precisely at the time, but yes. You probably want the projectile to come back to center of body, so that the player turning left and right doesn't change the "target x". Kneeling/standing should affect the target y though (base y + character height/2)
Note, these suggestions are only based on my experience with 2d shooters in general; the original games may do something different and experienced players may be put off if you don't replicate it.

killocan
Member #1,556
October 2001
avatar

Well, i tried hauwhwauahw needs lots and lots of little tweaks to be equal, but it's a start. Also i need to draw the animation for megaman firing this weapon, it's different from the usual gun shooting animation. Thanks all!

EDIT: Video showing the thing on game attached. Having problems with my YT account.

Go to: