How can I have different food items in a snake game?
This is a piece of the code I'm given:

void display_food_at(int8_t x, int8_t y) { 
    set_display_attribute(31); 
    display_character_at(x, y, '#'); 
}

I believe I have to add something somewhere around it..???

#include <stdlib.h>

...

display_character_at(x, y, rand() % 128);

:)

Thanx Narue that was so helpful :D
But can u tell me what does this part of the code mean?

rand() % 128);

>But can u tell me what does this part of the code mean?
It's one way to get a random number within the range of 0-127. I was joking though. You'll get all manner of weird goings-on if you use that. A better way is to use the random number as an index into an array of selected characters:

#include <string.h>

char food[] = "%&*^$#@";

display_character_at(x, y, rand() % strlen(food));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.