using UnityEngine;

public class Player:MonoBehaviour {

public Vector2 jumpForce = new Vector2(0,300);
	public AudioClip Explosion;
void Update()
{if(Input.GetKeyUp("space"))
{
rigidbody2D.velocity = Vector2.zero;
rigidbody2D.AddForce(jumpForce);
}

            // Die by being off screen
            Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position);
            if (screenPosition.y > Screen.height || screenPosition.y < 0)
            {
                  Die();
            }
      }
     
      // Die by collision
      void OnCollisionEnter2D(Collision2D other)
      {
		AudioSource.PlayClipAtPoint (Explosion, transform.position); 
            Die();

      }
     
      void Die()
      {

		Application.LoadLevel(Application.loadedLevel);
		 
      }

}

