// CONSTANTES E VARIÁVEIS INICIAIS #define PIN_BUTTON 2 #define PIN_AUTOPLAY 1 #define PIN_READWRITE 10 #define PIN_CONTRAST 12 #define SPRITE_RUN1 1 #define SPRITE_RUN2 2 #define SPRITE_JUMP 3 #define SPRITE_JUMP_UPPER '.' // Use o caractere '.' para a cabea #define SPRITE_JUMP_LOWER 4 #define SPRITE_TERRAIN_EMPTY ' ' #define SPRITE_TERRAIN_SOLID 5 #define SPRITE_TERRAIN_SOLID_RIGHT 6 #define SPRITE_TERRAIN_SOLID_LEFT 7 #define HERO_HORIZONTAL_POSITION 1 // Posição horizontal do jogador na tela #define TERRAIN_WIDTH 16 #define TERRAIN_EMPTY 0 #define TERRAIN_LOWER_BLOCK 1 #define TERRAIN_UPPER_BLOCK 2 #define HERO_POSITION_OFF 0 // O jogador está invisível #define HERO_POSITION_RUN_LOWER_1 1 // Jogador está correndo na linha de baixo (pose 1) #define HERO_POSITION_RUN_LOWER_2 2 // (pose 2) #define HERO_POSITION_JUMP_1 3 // Começando a pular #define HERO_POSITION_JUMP_2 4 // Metado do caminha pra cima #define HERO_POSITION_JUMP_3 5 // Pulo está na linha de cima #define HERO_POSITION_JUMP_4 6 // Pulo está na linha de cima #define HERO_POSITION_JUMP_5 7 // Pulo está na linha de cima #define HERO_POSITION_JUMP_6 8 // Pulo está na linha de cima #define HERO_POSITION_JUMP_7 9 // Metado do caminho pra baixo #define HERO_POSITION_JUMP_8 10 // Quase aterrisando #define HERO_POSITION_RUN_UPPER_1 11 // O jogador está correndo na linha de cima (pose 1) #define HERO_POSITION_RUN_UPPER_2 12 // (pose 2) static char terrainUpper[TERRAIN_WIDTH + 1]; static char terrainLower[TERRAIN_WIDTH + 1]; static bool buttonPushed = false; void initializeGraphics(){ static byte graphics[] = { // Run position 1 B01100, B01100, B00000, B01110, B11100, B01100, B11010, B10011, // Run position 2 B01100, B01100, B00000, B01100, B01100, B01100, B01100, B01110, // Jump B01100, B01100, B00000, B11110, B01101, B11111, B10000, B00000, // Jump lower B11110, B01101, B11111, B10000, B00000, B00000, B00000, B00000, // Ground B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111, // Ground right B00011, B00011, B00011, B00011, B00011, B00011, B00011, B00011, // Ground left B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000, }; int i; // Skip using character 0, this allows lcd.print() to be used to // quickly draw multiple characters for (i = 0; i < 7; ++i) { lcd.createChar(i + 1, &graphics[i * 8]); } for (i = 0; i < TERRAIN_WIDTH; ++i) { terrainUpper[i] = SPRITE_TERRAIN_EMPTY; terrainLower[i] = SPRITE_TERRAIN_EMPTY; } }