<img class="an-image" src="http://3.bp.blogspot.com/- Wz6SIc_Zfng/Vi4Yj9DPKnI/AAAAAAAADN4/nY1_L9r4r_4/s1600/simple.png" />

Senin, 15 Juni 2015

Script Game Pesawat Dengan Unity (Tugas Pengantar Teknologi Game)


var projectile :Transform;
var soketprojectile :Transform;

static var liveplayer :int =5;

var kecepatan : float = 10.0;

function Update () {

var kirikanan : float = Input.GetAxis ("Horizontal") * kecepatan;
var majumundur : float = Input.GetAxis ("Vertical") *  kecepatan;

kirikanan *=Time.deltaTime;
majumundur *=Time.deltaTime;


transform.Translate ( kirikanan,0,0);
transform.Translate ( 0,majumundur,0);

transform.position.x=Mathf.Clamp(transform.position.x,-11,11);
transform.position.y=Mathf.Clamp(transform.position.y,-8,8);


if (Input.GetButtonDown("Jump"))
{
Instantiate(projectile,soketprojectile.position,soketprojectile.rotation);

}
if (liveplayer<=0)
{
Application.LoadLevel("Kalah");
}
}

function OnTriggerEnter (other :Collider)
{
if (other. gameObject.tag=="Enemy")
{
nyawaplayer();
}
}
function nyawaplayer()
{
liveplayer-=1;
}

function OnGUI()
{
GUI.Label(Rect(250,30,100,20),"NYAWA :" + liveplayer);

}

Tidak ada komentar:

Posting Komentar