简单的贪吃蛇游戏,目前存在的缺陷:没有死亡判定,没有障碍物,没有UI,可以按和移动方向相反的按键
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Control1 : MonoBehaviour
{
Vector3 oldPosition;
// Start is called before the first frame update
void Start()
{
InvokeRepeating("snakeMove", 0.1f, 0.5f);
}
// Update is called once per frame
void Update()
{
}
private void snakeMove()
{
oldPosition = transform.position;
float H = Input.GetAxis("Horizontal");
float V = Input.GetAxis("Vertical&