Jump to content

Photo

Attack Movements


  • Please log in to reply
3 replies to this topic

#1 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 17 May 2009 - 10:21 AM

Since I suck terribly at math, and all these require sin and cos and all that other 'fun' math stuff. Or so I'd imagine. They all involve curves and stuff like that.

Anyways, I'm making a final boss for my one map quest with a script. I've got a good idea on how to do everything, except for a few things. Since I'm basing him off of the final boss of Prinny: CIRBTH, I want to keep it fairly accurate. So, here's my problem:

1. I need a way to get a fire-ball to curve toward Link. (It's always moving horizontally, but it's supposed to bend up or down, depending on whether he is above it or not.) Video to describe what I mean:(Spoilers for Prinny) Seen sorta at 0:45.
2. I can't describe this one very well, so here's a video: (Contains spoilers for Prinny) Seen at 0:28 I'd imagine sin and cos for that, but again, math is my weak spot, so I don't know.
3. A spiral attack that launches fire-balls that shoot out while keeping a circlular path.
4. Getting something to make a curve motion rather than a straight path from point a to point b. (Not important, but would be nice.)

I'd really appreciate it if anyone could help me with this.



#2 Joe123

Joe123

    Retired

  • Members

Posted 17 May 2009 - 10:33 AM

Circles.

In a circle, you use a variable (which we'll call t) to work out the x and y coordinates of the circle, using sine and cosine.

You increment t (well, or increase it by more than 1 if you want to go round the circle faster) each frame, which moves whatever it is round the circle.

So something a little like this will create a circle:
CODE
int t;
while(true){
    something->X = cos(t);
    something->Y = sin(t);
    t++;
Waitframe();


The next thing we need to be able to do is specify the centre of the circle.
All we have to do for that is add it onto the sine and cosine values, abit like this:
CODE
int t;
while(true){
    something->X = cos(t) + centrex;
    something->Y = sin(t) + centrey;
    t++;
Waitframe();


The only problem now is that we haven't specified the radius of the circle.
To do that, we multiply cosine and sine by our radius value.

So something which spirales outwards from (centrex,centrey) might look a little like this:
CODE
int t;
int radius = 1;
while(true){
    something->X = radius*cos(t) + centrex;
    something->Y = radius*sin(t) + centrey;
    t++; radius++;
Waitframe();


And that's circles for you!
I might do the other ones some other time.

#3 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 17 May 2009 - 12:17 PM

Thank you so much! icon_biggrin.gif

I had a thought, actually. For my fourth idea, I'm thinking I find the mid-point between where the boss is and where he will be, and use that as the centre so the boss will move along the circular path you described. Would something like that work?

#4 Joe123

Joe123

    Retired

  • Members

Posted 17 May 2009 - 12:52 PM

I would say parabolic motion is better than circular if you want to move along a path from A to B.

If you start off moving round a circle, you'll be going in a completely different direction initially than where you intend to go to.
If you're moving along a parabola, (depending on how stretched it is), you're going where you want to get to, just in a curved path.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users