PDA

View Full Version : One-Way Tiles



C-Dawg
10-31-2006, 12:08 AM
Under Saffith's careful guidance, I have completed another script that actually works! This one codes a one-way tile. Link is prevented from walking through the tile in exactly one direction. Works identically to the one-way blocks in Adventures of Lolo.




// ===========================================
// One_way: Sets up a one-way block. Uses the
// FFC arguments to determine which way the block
// will prevent Link from moving.
// 0 = Prevent Link from moving North
// 1 = Prevent Link from moving East
// 2 = Prevent Link from moving South
// 3 = Prevent Link from moving West
// ===========================================


ffc script one_way {


void run(int direction){

while(true){

if (direction == 0){

if ((Abs(Link->X - this->X) < 16) &&
(Link->Y < this->Y + 16) && (Link->Y > this->Y) &&
(Link->InputUp)){Link->InputUp = false; }
}

if (direction == 1){

if ((Abs(Link->Y - this->Y) < 16) &&
(Link->X > this->X - 16) && (Link->X < this->X) &&
(Link->InputRight)){Link->InputRight = false; }
}

if (direction == 2){

if ((Abs(Link->X - this->X) < 16) &&
(Link->Y > this->Y -16) && (Link->Y < this->Y) &&
(Link->InputDown)){Link->InputDown = false; }
}

if (direction == 3){

if ((Abs(Link->Y - this->Y) < 16) &&
(Link->X < this->X + 16) && (Link->X > this->X) &&
(Link->InputLeft)){Link->InputLeft = false; }
}

Waitframe();

} // end of while loop


} // end of void run

} // end of ffc script