/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / getpixel help

Username:     
Password:     
             

Forum

# 1   2011-02-18 17:55:54 getpixel help

breez
New member
Registered: 2010-10-29
Posts: 1

getpixel help

Hi,

I programmed a simple snake line on my primer with freertos. This line gets longer when you drive with the joystick. My problem is that I what to get an Game Over when the snake touch itself. The snakes colour is red and the display is white. So I tried it with this code

in lcd.c

  u16 LCD_GetPixel( u8 x, u8 y )
        {
        u16 val;

        LCD_RectRead( x, y, 1, 1, (u8*)&val );

        return val;
        }

in main.c

if (LCD_GetPixel(wurm[idx].xs+4,wurm[idx].ys+4) != RGB_WHITE)
            {
                killWurm(idx, farbe, pcstring, &xMessage);
                continue;
            }

void killWurm(int idx, int farbe, char *pcString, xWurmMessage *xMessage)  //Wenn der Wurm eine Wand berührt = Game Over
{
   wurm[idx].len = -wurm[idx].len;
   xMessage->dx=0;
   xMessage->dy=0;
    DRAW_SetTextColor(farbe);
   DRAW_DisplayString( MSG_X, MSG_Y, pcString, strlen( pcString ));
}

char pcstring[15];
strcpy(pcstring,"GAME OVER");

the problem is when I start the game nothing happend. The snake doesn't move.I think that the LCD_GetPixel function doesn't work correct.you have ideas?

regards
breez

Offline

 

# 2   2011-02-19 00:19:14 getpixel help

Jalwa999
New member
Registered: 2011-02-19
Posts: 1

Re: getpixel help

Hi,

I successfully tried the program with Primer2.

Offline

 

Board footer