using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class controls : MonoBehaviour
{
// Start is called before the first frame update
public float speed = 2.5f;
public Rigidbody2D rigibody;
public float force;
public float minimalHeight;
public bool isCheatMode;
public SpriteRenderer[] rendrers;
void Start()
{
rendrers[5].color = Color.red;
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector2.left * Time.deltaTime * speed);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(Vector2.right * Time.deltaTime * speed);
}
if (Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody2D>().AddForce(Vector2.up * force, ForceMode2D.Impulse);
}
if (transform.position.y < minimalHeight && isCheatMode)
{
rigibody.velocity = new Vector2.(x: 0, y: 0,);
transform.position = new Vector3.(x: 0, y: 0, z: 0);
}
else if (transform.position.y < minimalHeight)
Destroy(gameObject);
}
}