PDA

View Full Version : Getting the position of another FFC



C-Dawg
10-18-2006, 11:46 AM
I'd like to be able to have FFCs interact. Specifically, I'm hoping to be able to make one FFC move around while the second FFC orbits it, and be able to make a dozen or so FFCs move in a "NES snake" fashion where they all follow the leader after some delay. Obviously, there will be other applications for moving more than one FFC at once.

I'm looking at the Zscripts created so far and I don't see how I can use a script to control multiple FFCs, or failing that, how I can grab information about FFC A in a script running on FFC B. Can anyone explain how this can be accomplished?

Saffith
10-18-2006, 05:31 PM
That can be done, I think, but you might have to be a bit clever about it...

For now, the closest there is to what you want is this:

ffc ffcPtr=Screen->LoadFFC(num);
That just gives you another pointer to work with.

There are some limits to that. For one, you can't get an FFC by its position in the list relative to the current one. If you don't want to hard-code the number, you'll have to take it as an argument. And you can't create arrays, so the maximum number of pointers you load has to be fixed.
Also, there's no way to tell what script an FFC is running after you load it, so you can only use their common parameters—position, velocity, flags, etc. I'm hoping that much, at least, will change.

C-Dawg
10-18-2006, 07:24 PM
All I really need is the position of the other FFCs to do things that cause the FFCs to interact. I'm not sure I follow what your statement does, though. Can you walk me through the syntax?

Saffith
10-18-2006, 08:23 PM
The function just returns a pointer to another FFC. Keep track of that, and you can access all it's parameters the same way you would with this.


ffc ptr=Screen->LoadFFC(2); // Load pointer to FFC #2

// After that, you can access things like
ptr->X; // position,
ptr->Vy; // velocity,
ptr->Flags[0]; // flags,
ptr->EffectHeight; // etc...

C-Dawg
10-18-2006, 11:27 PM
Code looks fine. But it's certain that two FFCs just can't cooexist on the same screen. Try setting up a screen where one FFC is supposed to orbit the other. The second FFC can have code or not. Either way, it will shoot off the screen and the orbiting one will remain motionless.