i have written code to move a dot from on end of the lcd screen to the other end.

/*move dot across the creen with pixel increments of 10*/
      for(x=10;x<120;x+=20)
       {
            Glcd_Dot(x,y,0);
            Glcd_Dot(x,y,1);
            Glcd_Fill(0);
               delay_ms(100);
       }

i have seen examples in C, but this is on a 128x64 pixel lcd screen, i use Mikro c to write the code. it has some functions like Glcd_Rectangle(); for drawing rectangles but i just dont know how to implement the following:

>detect when snake's head makes collision with fruit.
> make a score tab that shows the score on th top of the lcd screen .
> detect if the snake head has hit a wall or touched its tail
>randomly generate fruit on the lcd screen

>randomly generate fruit on the lcd screen

rand() function

> make a score tab that shows the score on the top of the LCD screen .

Well, since you can lighten up pixels one by one, you can create functions to draw numbers this way.It's not a big deal ;)

> detect if the snake head has hit a wall or touched its tail

That's a little bit harder than the previous ones.
Each pixel could be represented by a structure, which has at least 3 options('has snake piece on it','has fruit on it','is a wall').
So this way, you'd have 3*2^10(3*128*64/8) byte sized structure array.
And now when the snake moves, you check in the structure array to determine what is the next pixel where the snake would be moving.
There sure are better solutions but this is how I'd do it.

Andrew

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.