-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkontrol.cs
45 lines (38 loc) · 1.12 KB
/
kontrol.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class kontrol : MonoBehaviour {
Rigidbody2D fisika;
public Text teksSkor;
public float gayaKeatas;
public int skor;
public GameObject panelGameOver;
// Use this for initialization
void Start() {
fisika = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update() {
if (Input.GetMouseButtonDown(0))
{
fisika.velocity = Vector2.zero;
fisika.AddForce(new Vector2(0f, gayaKeatas));
}
}
public void game_ulangin()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("skore"))
{
skor += 10;
teksSkor.text = "Score " + skor.ToString();
}else if(collision.gameObject.CompareTag("rintangan")) {
panelGameOver.SetActive(true);
}
}
}