PDA

View Full Version : Vacuum



Joe123
07-11-2008, 01:02 PM
I'm posting this, partly because then I can't ever loose it, and partly because some other people may also find it useful, although probably not in it's current form.

I needed a 'suction' script, so after quite a bit of trawling through topics, I found one by Linkus, but it didn't really work properly, so I've re-written it to function nicely.
So Linkus helped, and I also used a bit of code that jman posted from the source code as a guide too.

Anyway;


ffc script vacuum{
void run(){
int angle; int xdifference; int ydifference;
while(true){
xdifference = this->X-Link->X;
ydifference = this->Y-Link->Y;
angle = ArcTan(ydifference,xdifference);
if(angle<0) angle += 2*PI;

if(angle==PI) this->X++;
else if(angle==PI/2) this->Y--;
else if(angle==PI*3/2) this->Y++;
else if(angle==0 || angle==2*PI) this->X--;
else if(angle<PI/2){this->X--;this->Y--;}
else if(angle<PI){this->X--;this->Y++;}
else if(angle<PI*3/2){this->X++;this->Y++;}
else{this->X++;this->Y--;}
Waitframes(3);
}
}
}

Sucks the ffc with the script attached over to Link.
Not really all that useful, but quite fun to watch for a bit, and I'm sure if anyone else needed a suction script, it'd be good for reference.

The_Amaster
07-11-2008, 01:09 PM
so...it's more like a magnetic script? The combos gravitate towards Link?

Joe123
07-11-2008, 01:11 PM
Well yes, the freeform combo that the script is attached to moves over to Link.

C-Dawg
07-11-2008, 06:15 PM
This achieves a more constant velocity than the standard "if left of link, move left, if below link, move up" version of this script, I take it?

SotW
07-11-2008, 06:21 PM
Well it just seemed easier for me.
I plan to just use a quarter of it later, cause I'm creating a suck script for Kirby.

It pulls the object in diagonally, then in a horizontal or vertical line.
I don't know if it acheives a more constant velocity, but it will always converge to a point, whereas the if(left) Vx = 1; method you have to stop when it gets there.

EDIT: Oops, I'm still on this account.
Didn't mean to be >_<

~Joe123

Gleeok
07-11-2008, 09:39 PM
Neat-o. The script I wrote a while ago doesn't quite suck as much as this one, since your version sucks equally as well in 360 degrees.

I think I'll turn this into a void() function so I can have the option of whether to make it suck or blow, or suck and blow at the same time...or better yet, be able to specify any on-screen object to get sucked or blowed. :D

...Seriously though. :p

(fantastic)

The_Amaster
07-11-2008, 11:17 PM
I plan to just use a quarter of it later, cause I'm creating a suck script for Kirby.
I am...intrigued

Joe123
07-12-2008, 05:09 AM
Ah, you haven't heard about it over here yet.
Hrm.

Well, at Pure, we're (well, four of us are) working on a Kirby's Adventure tileset.
AgentLym and Blaman are ripping the graphcis (it's AL's set really, it was his idea originally), Zemious is spriting some subscreen graphics and things, and I'm re-creating the game via scripting in ZC.
So far, I have Jump, Fly and Slide tackle sorted out, and I'm working on Suck at the moment.


And I'm glad you're finding it useful Gleeok, I didn't think it was that likely that anyone else did, but I posted it anyway just in case.