Lukket

online snake game

Job Description:

ok so I am learning to code some old school C code to make a game that is cross platform and can be played over the network

I am trying to split the game up into header files and functions and definitions into other c files

snake.c

game.c

game.h

I have come across these errors and it will not compile but the issue here is the issues are not correct.

snake.c:16:1: warning: '/*' within block comment [-Wcomment]

/*

^

snake.c:100:61: error: use of undeclared identifier 'ROWS'; did you mean 'COLS'?

if (next.x < 0 || next.x >= COLS || next.y < 0 || next.y >= ROWS) {

^~~~

COLS

/Library/Developer/CommandLineTools/SDKs/[login to view URL]:1208:32: note: 'COLS' declared here

extern NCURSES_EXPORT_VAR(int) COLS;

^

snake.c:105:21: warning: ordered comparison between pointer and integer ('int' and 'int *')

for (int i = 1; i < length; i++) {

~ ^ ~~~~~~

snake.c:155:1: error: unterminated function-like macro invocation

getmaxyx(stdscr,

^

/Library/Developer/CommandLineTools/SDKs/[login to view URL]:913:9: note: macro 'getmaxyx' defined here

#define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win))

^

snake.c:215:1: error: expected '}'

^

snake.c:153:12: note: to match this '{'

int main() {

^

2 warnings and 3 errors generated.

game.c:15:1: warning: '/*' within block comment [-Wcomment]

/*

^

game.c:51:18: error: implicit declaration of function 'getNextPosition' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

Point next = getNextPosition(snake[0], direction);

^

game.c:51:11: error: initializing 'Point' with an expression of incompatible type 'int'

Point next = getNextPosition(snake[0], direction);

^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

game.c:52:9: error: implicit declaration of function 'checkCollision' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

if (checkCollision(next, rows, cols)) {

^

game.c:52:9: note: did you mean 'check_collision'?

./game.h:19:5: note: 'check_collision' declared here

int check_collision(Point next, Point *snake, int length, int rows, int cols);

^

game.c:57:11: error: implicit declaration of function 'checkCollisionWithSnake' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

if (checkCollisionWithSnake(next, snake[i])) {

^

game.c:63:9: error: implicit declaration of function 'checkFoodCollision' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

if (checkFoodCollision(next, food)) {

^

game.c:63:9: note: did you mean 'checkCollision'?

game.c:52:9: note: 'checkCollision' declared here

if (checkCollision(next, rows, cols)) {

^

game.c:65:14: error: implicit declaration of function 'generateFood' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

food = generateFood(rows, cols);

^

game.c:65:12: error: assigning to 'Point' from incompatible type 'int'

food = generateFood(rows, cols);

^ ~~~~~~~~~~~~~~~~~~~~~~~~

game.c:71:5: error: implicit declaration of function 'updateSnake' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

updateSnake(snake, next, length);

^

1 warning and 8 errors generated.

for example chatGPT reveals this issue:

It seems that you have used the incorrect name for the number of columns in the terminal window. The correct name is COLS instead of ROWS. You can resolve the error by changing the following line:

Copy code

if (next.x < 0 || next.x >= COLS || next.y < 0 || next.y >= ROWS) {

to

Copy code

if (next.x < 0 || next.x >= COLS || next.y < 0 || next.y >= ROWS) {

Færdigheder: C++ Programmering, C programmering, C# Programmering, Objective C, Software Arkitektur

Om klienten:
( 41 bedømmelser ) Battery Hill, Australia

Projekt ID: #35904958

17 freelancere byder i gennemsnit $23/timen for dette job

vladang

Hello... I am interested

$20 AUD / time
(248 bedømmelser)
7.1
michealperfect

Hello Chelson A., We would like to grab this opportunity and will work till you get 100% satisfied with our work. We are an expert team which have many years of experience on C Programming, C# Programming, Software A Flere

$20 AUD / time
(13 bedømmelser)
5.0
luckyjagritiwari

Hello sir I have done lot of games in unity game engine and I have more then 7 years experience in unity game engine and I can do any type of games so please send me more details about your game project and I will give Flere

$20 AUD / time
(3 bedømmelser)
5.1
wanjin1227

Hi! How are you? My main skill is the powerful reversing & the powerful debugging & Customizing opensource & the optimized System Design & the code based optimization . Skill Set: • C/C++/Delphi/C#/Qt/Golang: for 12 Flere

$25 AUD / time
(1 bedømmelse)
3.4
muthokieve

Offer! Offer! Offer! Greetings and well wishes! Welcome to my profile, where quality and client satisfaction are of paramount importance. I have worked with many clients in other platforms across the world and whom I w Flere

$20 AUD / time
(0 bedømmelser)
0.0
DragonGril0923

Hello sir I am a Senior Developer specialized in desktop application development having an experience of more than 8+ years. I am very excited to see your job posting as I am confident that I am a perfect fit for what Flere

$20 AUD / time
(0 bedømmelser)
0.0
Avdheshkumar05

Hi, we have experienced team for game applications like your requirement and we are expert in the same field. We also have ready games available for your satisfaction. Let's have a quick chat to discuss and process fur Flere

$20 AUD / time
(0 bedømmelser)
0.0
rikidev877

Hello, How are you ? I have rich experience while I had worked as C developer. To discuss about this task, please contact me.

$20 AUD / time
(0 bedømmelser)
0.0
contezer0

Your code is a mess, you put two main() in snake.c and another one in game.c, for instance. Also, be careful about cols and COLS, they're different variables (or constants) so be careful! That said, if you want i can r Flere

$15 AUD / time
(0 bedømmelser)
0.0