1 line of code.
A downloadable game for Windows
Made this in one line. try the code for yourself.
Source code:
using System.Collections; using UnityEngine.SceneManagement; using UnityEngine.UI; using System.Collections.Generic;using UnityEngine;public class GameManager : MonoBehaviour{ public Text t; private int score; public GameObject d; void Start(){ spawn(); }private void Update(){ t.text = "Score: " + score; if (transform.position.x < -10) transform.position = new Vector3(9, transform.position.y); if (transform.position.x > 10) transform.position = new Vector3(-9, transform.position.y); } void FixedUpdate(){ if (Input.GetKey(KeyCode.A)){ transform.position -= new Vector3(.1f, 0); } if (Input.GetKey(KeyCode.D)) { transform.position += new Vector3(.1f, 0); } }private void OnCollisionEnter2D(Collision2D collision){ if (collision.gameObject.name.Contains("ddong")) { Destroy(gameObject); SceneManager.LoadScene("End"); } } void spawn() { GameObject c = Instantiate(d, new Vector2(Random.Range(-10f, 10f), 6), Quaternion.identity); c.GetComponent<Rigidbody2D>().gravityScale = Random.Range(.5f, 2.5f); Destroy( c , 10) ; Invoke("spawn", Random.Range(.5f, 1f)); score++; print(score); } }
Status | Released |
Platforms | Windows |
Author | not Official Unity |
Download
Download
Windows.zip 22 MB
Comments
Log in with itch.io to leave a comment.
"New Text"