Day 1 Finished! Got the bare bones of the game functional. It's basically a game without any polish at the smallest scope possible.

This commit is contained in:
Gregory Campbell
2020-07-11 01:42:26 -04:00
parent c8f1a8291a
commit 0893d08a17
24 changed files with 1038 additions and 63 deletions
+62
View File
@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerScript : MonoBehaviour
{
public float speed;
public GameObject bullet;
private float translation;
private float rotation;
private float nextFire = 0.5f;
private float myTime = 0.0f;
private Rigidbody2D rb;
void Awake()
{
rb = this.GetComponent<Rigidbody2D>();
}
void Update()
{
myTime += Time.deltaTime;
if(Input.GetButton("Fire1") && myTime > nextFire)
{
nextFire = myTime + 0.5f;
Instantiate(bullet, transform.position, Quaternion.Euler(0,0,Random.Range(0.0f, 360.0f)));
nextFire = nextFire - myTime;
myTime = 0.0f;
}
}
void FixedUpdate()
{
rb.velocity =
new Vector2(Input.GetAxis("Horizontal") * speed, Input.GetAxis("Vertical") * speed);
}
void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.tag == "Bullet")
{
Physics2D.IgnoreCollision(
other.gameObject.GetComponent<Collider2D>(), GetComponent<Collider2D>());
}
if(other.gameObject.tag == "Enemy")
{
Destroy(gameObject);
}
}
}