/***********************************************************************
 * _switch1# Entity Script
 * 
 * Author: GD + Switch contest entries
 *
 * Date:   7 July 2002
 *
 * Desc:   A floor Switch Script, becuase it has a parameter, the switch 
 *		   can have several different appearances.
 *
 * Usage:  Use isPushed() to see if this switch is currently pressed.
 *
 * Sprites:
 *         
 **********************************************************************/
#include <entity>
#include <general>
#include <core>

//==================================
//   Global Data
//==================================
// Create Strings to hold the sprite codes
new width;
new height;

//----------------------------------------
// Name: main()
//----------------------------------------
main()
{
	if (FirstRun())
	{
		// Record the width and height of the main sprite for later use
		width  = GetWidth("opject_trigger");
		height = GetHeight("opject_trigger");
		SetImage("this", "_nullsprite");
	}
	
	if (isActive("this"))
	{
		new x = GetX("this");
		new y = GetY("this");
		
		SetCollisionRect("this",0,false,x - 4, y - 4, x + width + 4, y + width + 4)
		
		if(Collide("this","player1"))
		{
			SetGlobal(799,0);
		}
		
		// ==============================================
		// Check if the Player is standing on the switch
		// ==============================================
		// You could also use the Collide() fuction for this.
		if (NearPoint(x, y - (height / 3), GetX("player1"), GetY("player1"), width / 3))
		SetPushedFlag("this", true);
		else
		SetPushedFlag("this", false);
	}
}





