using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spaceship : MonoBehaviour {
    public float speed = 4.0f;
    private Rigidbody2D rb;
    private int time = 0;

    void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    // Use this for initialization
    void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetKey(KeyCode.LeftArrow) &&
            transform.localPosition.x > -10)
        {
            transform.position = transform.position +
                Vector3.left * speed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.RightArrow) &&
            transform.localPosition.x < 9.5)
        {
            transform.position = transform.position +
                Vector3.right * speed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.UpArrow) &&
            transform.localPosition.y < 6)
        {
            transform.position = transform.position +
                Vector3.up *
                speed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow) &&
            transform.localPosition.y > -4)
        {
            transform.position = transform.position +
                Vector3.down * speed * Time.deltaTime;
        }
    }
}
