Exemplo n.º 1
0
static void dla_plot(int x, int y, uint8_t r,uint8_t g , uint8_t b, float br)
{
	uint8_t o_red = 0;
	uint8_t o_green = 0;
	uint8_t o_blue = 0;

	getLedXY(x,y,&o_red,&o_green,&o_blue);

	r=br*r+((1-br)*o_red);
	g=br*g+((1-br)*o_green);
	b=br*b+((1-br)*o_blue);
	setLedXY(x, y, r,g,b);


}
Exemplo n.º 2
0
static int try_go(struct racer *r, int dir) {
    int dx = 0, dy = 0;
            
    switch(dir) {
    case DIR_UP:
        dy = -1;
        break;
    case DIR_LEFT:
        dx = 1;
        break;
    case DIR_DOWN:
        dy = 1;
        break;
    case DIR_RIGHT:
        dx = -1;
        break;
    }

    int nx = r->x + dx, ny = r->y + dy;
    if (nx < 0 || nx >= LED_WIDTH || ny < 0 || ny >= LED_HEIGHT)
        return 0;

    uint8_t rgb[3];
    getLedXY(nx, ny, rgb, rgb + 1, rgb + 2);

    int success = 0;
    switch(r->mode) {
    case MODE_ALIVE:
        success = rgb[0] < 128;
        break;
    case MODE_ZOMBIE:
        success = rgb[0] > 127;
        break;
    }

    if (success) {
        r->x = nx;
        r->y = ny;
        r->dir = dir;
    }
    return success;
}