//#define TEST_MAIN_02 void loop() { #if defined( TEST_MAIN_01 ) smile(50,50,0); while(1); #endif #if defined( TEST_MAIN_02 ) for(int col=0; col <= (MAX_MOUTH_COL-1); col++) { for(int row=0; row< mouthMaxRow[col]; row++) { set_mouth(col,row,50,50,50); pixel_show(); //delay(400); clearPixels(); } } clearPixels(); pixel_show(); while(1); #endif // put your main code here, to run repeatedly: //set_brightness(1); // emo_content(); // delay(1000); //loadingFade(); //while(1); process_mouth(); // delay(100); }
void init_NeoPixels(void) { pixels = new Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); pixels->begin(); // This initializes the NeoPixel library. pixels->setBrightness(DEFAULT_BRIGHTNESS); clearPixels(); pixels->show(); }
void emo_content() { /*Émotion : Content**********************************************/ clearPixels(); eye(1,50,50,50); eye(2,50,50,50); //bouche_vide(); //Changer LED3 et LED45 //smile(50,50,50); delay(1000); }
void paintFrame(){ clearPixels(); // Clear this frame int x, y; for (x=0;x<5;x++){ //Calculate ray position and direction double cameraX = 2 * x / double(5) - 1; double rayPosX = playerX; double rayPosY = playerY; double rayDirX = playerDirX + playerPlaneX * cameraX; double rayDirY = playerDirY + playerPlaneY * cameraX; //The current tile of the ray int mapX = int(rayPosX); int mapY = int(rayPosY); //Length of ray from current position to next x or y-side double sideDistX; double sideDistY; //How much the ray moves in each iteration in each axis double deltaDistX = sqrt(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX)); double deltaDistY = sqrt(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY)); double perpWallDist; int stepX;//Does the ray moves left (-1) or right (+1) int stepY;//Does the ray moves up (-1) or down (+1) int hit = 0; //Has the ray found a wall? int side; //Is it a horizontal or vertical wall? //calculate step and initial sideDist if (rayDirX < 0) { stepX = -1; sideDistX = (rayPosX - mapX) * deltaDistX; } else { stepX = 1; sideDistX = (mapX + 1.0 - rayPosX) * deltaDistX; } if (rayDirY < 0) { stepY = -1; sideDistY = (rayPosY - mapY) * deltaDistY; } else { stepY = 1; sideDistY = (mapY + 1.0 - rayPosY) * deltaDistY; } //Keep moving the ray until it hits somthing while (hit == 0) { //jump to next map square, OR in x-direction, OR in y-direction if (sideDistX < sideDistY) { sideDistX += deltaDistX; mapX += stepX; side = 0; } else { sideDistY += deltaDistY; mapY += stepY; side = 1; } //Check if ray has hit a wall if (map[mapX][mapY] > 0) hit = 1; } //Calculate distance projected on camera direction (oblique distance will give fisheye effect!) if (side == 0) perpWallDist = fabs((mapX - rayPosX + (1 - stepX) / 2) / rayDirX); else perpWallDist = fabs((mapY - rayPosY + (1 - stepY) / 2) / rayDirY); //Intensity of color = 5/d^4 (hardcoded so it looks nice for this map size) double intensity= 5/(perpWallDist*perpWallDist*perpWallDist*perpWallDist); //Calculate color depending on map value int r,g,b; switch(map[mapX][mapY]){ case 1: //R r=255; g=0; b=0; break; case 2: //G r=0; g=255; b=0; break; case 3: //B r=0; g=0; b=255; break; case 4: //Y r=255; g=255; b=0; break; } //The height of the walls depends on distance, to create perspective int y; int height=2; if(perpWallDist>=3.2){ //This value is hardcoded based on the map size so it looks nice height--; } if(perpWallDist>=2.5){//This value is hardcoded based on the map size so it looks nice height--; } setPixel(x,2, r*intensity,g*intensity,b*intensity); //At least, walls are 1 px tall for(y=1;y<=height;y++){ //But they can be up to 5 px tall setPixel(x,2+y, r*intensity,g*intensity,b*intensity); setPixel(x,2-y, r*intensity,g*intensity,b*intensity); } } }
CCEPixelNode::~CCEPixelNode() { clearPixels(); }
P6::~P6() { clearPixels(); }