Raulin 0 Newbie Poster

Hi there..
I am currently making a snake game, by means of array set up of [50,50] of the snake, and the FLTK for the design of it's interface. As Quincy 2005 is the default IDE learnt in Univ, I do the c++ codings here. I already proceeded with the snake, it's movement (keypad directions), also the functions of it's tails (push back, pop back, and insert; these functions I adapted from the Vector functions). I did the codes regarding the food, but have problem on how to set different positions of it (by means of a box containing a JPEG image). I employed the random number functions to set random positions of this box in the game window.
Here is the code I managed to do (which am not sure whether i can just link the box in FLTK to the random number function)

void rand_food(Fl_Widget* w, void* v) //it's position changes randomnly every minute
{
int foodx; //x-axes for food
int foody; //y-axes for food
srand((unsigned)time(0));
for  (int count=0; count < 20 ; count++){
foodx = rand() % 50;	
foody = rand() % 70;
cout << foodx << foody << endl;
}
food->position(foodx, foody); //food is the name of box, which contained a JPEG image
Fl::repeat_timeout(1.0, rand_food);
food->redraw();
gamewindow->redraw();
}

However, the result is that, the box i set for the food is gone, eventhough the whole program compiled and my snake indeed moved around.
I really need help on how to actually setting up a food, just locate it at positions on the game area, change in a random positions at say, 1 minute? just like the normal snake game...? i don't think i should set up another array for the food since it will not move like the snakes..just it changes the positions in times..but i also not very sure about this..uhh...
please help me...
Many Thanks

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.