//Generates food on a random free spot public static void generateFood(headController head) { int counter = 0; int rightSpot = Random.Range(0, freeSpaceLeft); for (int y = 1; y <= 10; ++y) { for (int x = 1; x <= 18; ++x) { if (grid[y][x] == FREE) { if (counter == rightSpot) { grid[y][x] = FOOD; freeSpaceLeft--; head.makeFood(x, y); return; } counter++; } } } }
void Start() { tr_left = go_left.GetComponent <Transform>(); tr_right = go_right.GetComponent <Transform>(); c_head = FindObjectOfType <headController>(); }
void Start() { rb = GetComponent <Rigidbody>(); c_head = FindObjectOfType <headController>(); }