c++ – Local Function definitions are illegal – snake game

I am new to C++ and am using VS and have tried to follow a tutorial for a snake game but have been getting the C2601 error – the code I have done it below and I am not sure how to get rid of these errors, can anyone help?

#include <iostream>
using namespace std;
bool gameOver;
const int width = 20;
const int height = 20;
int x, y, fruitX, fruitY, score;
enum class eDirection { STOP = 0, LEFT, RIGHT, UP, DOWN };
eDirection dir;
void Setup()
gameOver = false;
dir = eDirection: :STOP;
x = width / 2;
y = height / 2;
fruitX = rand() % width;
fruitY = rand() % height;
score = 0;

Source link

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top