Author Topic: Boss Movement script.  (Read 3920 times)

zage

Boss Movement script.
« on: May 02, 2009, 02:00:12 AM »
Well I've been searching through some Tuts and I can't find anything on boss movement. Can someone help me?

Re: Boss Movement script.
« Reply #1 on: May 02, 2009, 02:19:16 AM »
Yeah, we don't have anything on Boss Movement yet, so here's the basics. Hopefully you'll understand, since I won't be going as in-depth as a tutorial would:

SetMovePosition01(X-coordinate, Y-coordinate, velocity);
Tells Danmakufu to make the boss start moving towards the X and Y coordinates specified, with the velocity you declare. Typically we use SetMovePosition03 instead of this one, because this one isn't very fluid.

SetMovePosition02(X-coordinate, Y-coordinate, frames);
Tells Danmakufu to make the boss start moving towards the X and Y coordinates specified, taking "frames" long to get there. 60 frames is one second, 120 frames is two seconds, etc.

SetMovePosition03(X-coordinate, Y-coordinate, weight, velocity);
Tells Danmakufu to make the boss start moving towards the X and Y coordinates specified, with the velocity you declared. This is a special movement function which includes "weight", which tells Danmakufu to make the boss decelerate as it's reaching it's goal, making a more fluid motion. A higher weight value will make the deceleration more sudden.

I'm ignoring SetMovePositionHermite(); because it is beyond my level of understanding. Probably doesn't have much use unless you want your movements to be really fluid and presice.

SetMovePositionRandom01(X-distance, Y-distance, velocity, left-boundry, top-boundry, right-boundry, lower-boundry);
Tells Danmakufu to make the boss move around randomly inside a rectangle that you declare. The boss will move the X and Y distance you tell it to, with the velocity you declare, within the rectangle you designate by declaring it's left-most coordinate, upper-most coordinate, right-most coordinate and lower-most coordinate.


You would use these functions just like calling a bullet in @MainLoop:
Code: [Select]
frame++;

if(frame==120){
SetMovePosition03(GetCenterX, GetCenterY, 10, 3);
}
Tells the boss, at frame 120, to move towards the center of the playing field with a moderate velocity and decelerate as it's reaching it's goal.
« Last Edit: May 08, 2009, 01:03:05 AM by Naut »

Halca

  • Kawaii Bastard
Re: Boss Movement script.
« Reply #2 on: May 17, 2009, 01:52:59 AM »
I want to have constant random movement for my spell card using SetMovePositionRandom01.  How can I do this?

Re: Boss Movement script.
« Reply #3 on: May 17, 2009, 02:00:51 AM »
Code: [Select]
frame++;

if(frame==120){
 SetMovePositionRandom01(rand(10, 50), rand(10, 50), 2, 100, 40, 348, 150);
 frame = 60;
}

Set your movement distance to be randomly generated (first two parameters), set the speed she'll that she'll move at (2) and set the boundry (left: 100 pixels, or somewhat close to the left side of the screen. Top: 40 pixels, or close to the top of the screen. Right: 348 pixels, or 100 pixels from the right side of the screen. bottom: 150 pixels from the top of the screen, or 90 pixels above the center of the screen). She will move randomly inside this boundry for the whole spell, because we reset "frame" to a lower number, so the code will repeat itself for another random location.

Halca

  • Kawaii Bastard
Re: Boss Movement script.
« Reply #4 on: May 17, 2009, 02:19:54 AM »
Thanks again :)

Halca

  • Kawaii Bastard
Re: Boss Movement script.
« Reply #5 on: May 17, 2009, 02:33:42 AM »
One thing I'd like to change.
I noticed that when the she moves she doesn't turn to the right or left.
How can I make this so?
Is it even do-able?

JormundElver

  • Baron Von Parakeet
Re: Boss Movement script.
« Reply #6 on: May 17, 2009, 03:03:09 AM »
For Rumia, this sample script properly animates her movements http://touhou.wikia.com/wiki/Touhou_Danmakufu:_Sample_03 .

Point of interest within that I believe is

    // set the graphic region
    sub setGraphicStop  { SetGraphicRect(  0,   0,  64,  64); }    // stopping
    sub setGraphicPose  { SetGraphicRect( 64,   0, 128,  64); }    // special pose
    sub setGraphicLeft  { SetGraphicRect(128,   0, 192,  64); }    // move left
    sub setGraphicRight { SetGraphicRect(192,   0, 256,  64); }    // move right

    // set the graphic region according to the moving direction
    sub setGraphicMove {
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } else {
            setGraphicRight;
        }
    }

Edit to mention that you'll obviously need more then the above chunk to animate her, but I think that's where they define the graphic boxes of her images, that are called upon when she moves.
« Last Edit: May 17, 2009, 03:05:04 AM by JormundElver »