text: // Game & Watch Octopus Simulator for ESPresso Lite
  //
  // Instructions
  //
  // ESPresso Lite V2.0
  // Button 1 (GPIO0): Game A, Move Left
  // Button 2 (GPIO13): Game B, Move Right
  // Button 1 + Button 2: Sound On/Off
  //
  // ESPresso Lite V1.0
  // Button 1 (FLASH): Game A, Move Left
  // Button 2 (USER): Game B, Move Right
  // Button 1 + Button 2: Sound On/Off
  //
  // Gamepad
  // A: Game A
  // B: Game A
  // Left: Move Left
  // Right: Move Right
  // Up: Increase Volume
  // Down: Decrease Volume
  //
  // Game A
  // Divers try to recover treasure from sunken ship raise it to their boat.
  // Giant octopus tries to prevent them.
  // 1. Press button 1. Highest previous score will be displayed. Game A begins when key is released.
  // 2. Press operation button 2, and one diver goes into the water.
  // 3. By pressing operation button 1 and 2, diver moves left and right to evade moving tentacles.
  //    When diver reaches treasure, press operation button 2 to place gems into bag.
  //   *Press button once, diver bags one gem, press button twice, two gems, ...
  // 4. One gem equals one point. Reach the boat, and earn 3 points.
  //   *If diver fails to pick up treasure, he can not return to boat.
  // 5. If octopus tentacle touches diver, score one miss! Diver vanishes from screen.
  //    When all three divers are gone, game ends.
  // 6. When player reaches a bonus score (200 or 500 points), any lost divers at the time are replaced in the boat.
  //    Tentacles move at increasing speed, then return to original speed every 100 points.
  //
  // Game B
  // Tentacles move faster than in Game A. In other respects, this game is same as Game A.
  
  #ifndef _GAME_OCTOPUS_H_
  #define _GAME_OCTOPUS_H_
  
  #include "Game.h"
  
  namespace octopus {
  const uint8_t amBitmap[(16 * 8) / 8] PROGMEM = { // am.png
    0xA2, 0x00, 0x55, 0x01, 0x57, 0x01, 0x55, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  
  const uint8_t backgroundBitmap[(128 * 64) / 8] PROGMEM = { // background.png
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFF, 0xFF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0xFF, 0x70, 0xF8, 0x0F, 0xF0, 0x87, 0xFF, 0xFF,
    0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x30, 0xC0, 0x01, 0xC2,
    0xEF, 0x01, 0xFE, 0xE1, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x1F, 0x7E,
    0x00, 0xFF, 0x87, 0xFF, 0x3F, 0xF8, 0x71, 0x06, 0xC0, 0x0F, 0x07, 0xF0,
    0x00, 0x80, 0x07, 0xE0, 0xFF, 0xFF, 0xFF, 0x07, 0x9E, 0xDF, 0x87, 0x1F,
    0x30, 0x03, 0x0C, 0x0C, 0x83, 0xCF, 0xE0, 0xFF, 0xFF, 0xE1, 0xFF, 0x00,
    0xF0, 0x03, 0xFF, 0xFF, 0xFF, 0xF0, 0xEF, 0x33, 0xF8, 0xF0, 0xFF, 0x1F,
    0xC0, 0xC0, 0x3F, 0x00, 0xE0, 0x37, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xFF,
    0x38, 0xC6, 0xFF, 0x0F, 0x80, 0x82, 0x07, 0x00, 0xE0, 0xA7, 0xFF, 0xFF,
    0xFF, 0xFF, 0xF7, 0xFF, 0x0F, 0xFF, 0xFF, 0x07, 0x00, 0x80, 0x03, 0x00,
    0xC0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0x01,
    0x00, 0x82, 0x01, 0x00, 0x80, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0xFF,
    0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x80, 0x19, 0x00, 0x80, 0xDF, 0xFF, 0xFF,
    0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x03, 0x10, 0x0E, 0x00, 0x84, 0x01,
    0x80, 0x03, 0xFC, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0xFF, 0xFF, 0x0F, 0xC3,
    0xC1, 0x01, 0x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FF,
    0xFF, 0xF4, 0xFF, 0xFF, 0x09, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xD4, 0xFF, 0xFF, 0x1A, 0x04, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xF4, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0xFF, 0x7F,
    0x11, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF,
    0xFF, 0xFB, 0xFF, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0x3F, 0x4C, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xEB, 0xFF, 0x1F,
    0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0xFF,
    0xFF, 0xF3, 0xFF, 0xAF, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0x4F, 0x10, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFB, 0xFF, 0x07,
    0x00, 0x00, 0x00, 0x00
  };
  
  const uint8_t colonBitmap[(8 * 8) / 8] PROGMEM = { // colon.png
    0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00
  };
  
  const uint8_t diverBitmap[17][(16 * 16) / 8] PROGMEM = {
    {0x70, 0x00, 0xF8, 0x00, 0xAC, 0x01, 0xFC, 0x01, 0xAC, 0x01, 0xFB, 0x00, 0x77, 0x06, 0xF8, 0x07, 0x70, 0x00, 0x73, 0x00, 0xCF, 0x00, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // diver0.png
    {0x70, 0x00, 0xF8, 0x00, 0xAC, 0x01, 0xFC, 0x01, 0xAC, 0x01, 0xFB, 0x00, 0x77, 0x06, 0xF8, 0x07, 0x70, 0x0C, 0x73, 0x1C, 0xCF, 0x3C, 0x80, 0x3F, 0x80, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // diver1.png
    {0xE0, 0x00, 0xB0, 0x01, 0xF8, 0x02, 0xB8, 0x03, 0xFB, 0x03, 0xF7, 0x01, 0xF8, 0x00, 0x73, 0x01, 0x73, 0x06, 0x7F, 0x06, 0x20, 0x00, 0x10, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}, // diver2.png
    {0xE0, 0x00, 0xB0, 0x01, 0xF8, 0x02, 0xB8, 0x03, 0xFB, 0x03, 0xF7, 0x01, 0xFC, 0x00, 0x73, 0x01, 0x73, 0x02, 0x7F, 0x06, 0x20, 0x07, 0x90, 0x07, 0x9C, 0x07, 0x9C, 0x07, 0x00, 0x03, 0x00, 0x00}, // diver3.png
    {0xC0, 0x01, 0xA0, 0x03, 0xF0, 0x06, 0xD0, 0x07, 0x76, 0x07, 0xEE, 0x03, 0xF0, 0x01, 0xE1, 0x0F, 0xF3, 0x0C, 0x7F, 0x00, 0x20, 0x00, 0x20, 0x00, 0x60, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00}, // diver4.png
    {0xC0, 0x01, 0xA0, 0x03, 0xF0, 0x06, 0xD0, 0x07, 0x76, 0x07, 0xEE, 0x03, 0xF0, 0x01, 0xE1, 0x0F, 0xF3, 0x0C, 0x7F, 0x18, 0x20, 0x38, 0x20, 0x78, 0x60, 0x78, 0xE0, 0x70, 0x00, 0x00, 0x00, 0x00}, // diver5.png
    {0x70, 0x00, 0xB8, 0x00, 0xEC, 0x01, 0x7C, 0x01, 0xDC, 0x01, 0xF8, 0x00, 0x70, 0x06, 0xFC, 0x07, 0x37, 0x00, 0x33, 0x01, 0xF0, 0x01, 0xF8, 0x01, 0x18, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x00, 0x00}, // diver6.png
    {0x70, 0x00, 0xB8, 0x00, 0xEC, 0x01, 0x7C, 0x01, 0xDC, 0x01, 0xF8, 0x00, 0x70, 0x06, 0xFC, 0x07, 0x37, 0x0C, 0x33, 0x1D, 0xF0, 0x1D, 0xF8, 0x3D, 0x18, 0x3C, 0x0E, 0x38, 0x0E, 0x00, 0x00, 0x00}, // diver7.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xB8, 0x0B, 0xE0, 0x07, 0x80, 0x03, 0x80, 0x07, 0xC0, 0x05, 0xE0, 0x19, 0xBC, 0x19, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver8.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x8F, 0x03, 0x87, 0x07, 0xC7, 0x05, 0xE3, 0x19, 0xBC, 0x19, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver9.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xB8, 0x0B, 0xE0, 0x07, 0x80, 0x7F, 0x80, 0x63, 0xC0, 0x01, 0xE0, 0x01, 0xBC, 0x01, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver10.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x8F, 0x7F, 0x87, 0x63, 0xC7, 0x01, 0xE3, 0x01, 0xBC, 0x01, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver11.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xB8, 0x0B, 0xE0, 0x07, 0x80, 0x03, 0x80, 0x07, 0xC0, 0x05, 0xE0, 0x19, 0xBC, 0x19, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver12.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x8F, 0x03, 0x87, 0x07, 0xC7, 0x05, 0xE3, 0x19, 0xBC, 0x19, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver13.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x9F, 0x03, 0xF7, 0x03, 0xC7, 0x01, 0xE3, 0x01, 0xBC, 0x01, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver14.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x9F, 0x03, 0xF7, 0x03, 0xC7, 0x01, 0xE3, 0x01, 0xBC, 0x01, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}, // diver15.png
    {0x00, 0x07, 0x80, 0x0F, 0xC0, 0x1D, 0xC0, 0x17, 0xD8, 0x1E, 0xBC, 0x0B, 0xEE, 0x07, 0x9F, 0x03, 0xF7, 0x03, 0xC7, 0x01, 0xE3, 0x01, 0xBC, 0x01, 0x1C, 0x01, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00}  // diver16.png
  };
  
  const uint8_t onTheBoatBitmap[2][(16 * 16) / 8] PROGMEM = {
    {0x70, 0x00, 0xF8, 0x00, 0xAC, 0x01, 0xFC, 0x01, 0xAC, 0x01, 0xF8, 0x00, 0x70, 0x00, 0x3C, 0x00, 0x73, 0x01, 0x73, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // diverOnTheBoat0.png
    {0x70, 0x00, 0xF8, 0x00, 0xAC, 0x19, 0xFC, 0x19, 0xAC, 0x2D, 0xF8, 0x36, 0x70, 0x7B, 0x3C, 0x78, 0x73, 0x78, 0x73, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  // diverOnTheBoat1.png
  };
  
  const uint8_t remainderBitmap[(16 * 16) / 8] PROGMEM = { // diverOnTheBoat2.png
    0x1C, 0x00, 0x3E, 0x00, 0x6B, 0x00, 0x7F, 0x00, 0x6B, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x08, 0x00, 0x3E, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  
  const uint8_t gameTypeBitmap[2][(32 * 8) / 8] PROGMEM = {
    {0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x22, 0xA3, 0x18, 0x28, 0x02, 0x54, 0x25, 0x44, 0x32, 0x57, 0x3D, 0x7C, 0xA2, 0x54, 0x05, 0x44, 0x1C, 0x57, 0x39, 0x44, 0x00, 0x00, 0x00, 0x00}, // gameA.png
    {0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x3C, 0x22, 0xA3, 0x18, 0x48, 0x02, 0x54, 0x25, 0x38, 0x32, 0x57, 0x3D, 0x48, 0xA2, 0x54, 0x05, 0x48, 0x1C, 0x57, 0x39, 0x3C, 0x00, 0x00, 0x00, 0x00}  // gameB.png
  };
  
  const uint8_t missArmBitmap[2][(8 * 8) / 8] PROGMEM = {
    {0x08, 0x08, 0x08, 0x0C, 0x0C, 0x00, 0x00, 0x00}, // missArm0.png
    {0x0C, 0x06, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00}  // missArm1.png
  };
  
  const uint8_t missDiverBitmap[(16 * 16) / 8] PROGMEM = { // missDiver.png
    0x30, 0x00, 0x30, 0x00, 0x20, 0x00, 0x5C, 0x00, 0x3E, 0x00, 0x6B, 0x00, 0x7F, 0x00, 0x6B, 0x00, 0x3E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  
  const uint8_t missLegsBitmap[2][(16 * 16) / 8] PROGMEM = {
    {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x19, 0x00, 0x03, 0x00, 0x0E, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // missLegs0.png
    {0x18, 0x00, 0x1C, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}  // missLegs1.png
  };
  
  const uint8_t numberBitmap[10][(8 * 8) / 8] PROGMEM = {
    {0x0E, 0x11, 0x11, 0x00, 0x11, 0x11, 0x11, 0x0E}, // number0.png
    {0x00, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00}, // number1.png
    {0x0E, 0x10, 0x10, 0x0E, 0x01, 0x01, 0x01, 0x0E}, // number2.png
    {0x0E, 0x10, 0x10, 0x0E, 0x10, 0x10, 0x10, 0x0E}, // number3.png
    {0x00, 0x11, 0x11, 0x0E, 0x10, 0x10, 0x10, 0x00}, // number4.png
    {0x0E, 0x01, 0x01, 0x0E, 0x10, 0x10, 0x10, 0x0E}, // number5.png
    {0x0E, 0x01, 0x01, 0x0E, 0x11, 0x11, 0x11, 0x0E}, // number6.png
    {0x0E, 0x11, 0x11, 0x00, 0x10, 0x10, 0x10, 0x00}, // number7.png
    {0x0E, 0x11, 0x11, 0x0E, 0x11, 0x11, 0x11, 0x0E}, // number8.png
    {0x0E, 0x11, 0x11, 0x0E, 0x10, 0x10, 0x10, 0x0E}  // number9.png
  };
  
  const uint8_t pmBitmap[(16 * 8) / 8] PROGMEM = { // pm.png
    0xA7, 0x00, 0x55, 0x01, 0x57, 0x01, 0x51, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };
  
  const uint8_t tentacleBitmap[5][5][(8 * 8) / 8] PROGMEM = {
    {
      {0x3C, 0xE6, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00}, // tentacle00.png
      {0xF8, 0x7E, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x00}, // tentacle01.png
      {0x03, 0x1E, 0xFC, 0x78, 0x30, 0x00, 0x00, 0x00}, // tentacle02.png
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    },
    {
      {0x3C, 0xE6, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00}, // tentacle10.png
      {0xF8, 0xDC, 0x6E, 0x3F, 0x00, 0x00, 0x00, 0x00}, // tentacle11.png
      {0x7C, 0x2E, 0x1F, 0x0F, 0x00, 0x00, 0x00, 0x00}, // tentacle12.png
      {0x3C, 0x3C, 0x1C, 0x0E, 0x06, 0x01, 0x00, 0x00}, // tentacle13.png
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    },
    {
      {0xFC, 0xDE, 0x6F, 0x3F, 0x00, 0x00, 0x00, 0x00}, // tentacle20.png
      {0x7E, 0x6F, 0x36, 0x1C, 0x18, 0x08, 0x00, 0x00}, // tentacle21.png
      {0x01, 0x03, 0x07, 0x07, 0x0F, 0x0E, 0x0C, 0x08}, // tentacle22.png
      {0x01, 0x03, 0x07, 0x07, 0x0F, 0x0E, 0x0C, 0x08}, // tentacle23.png
      {0x04, 0x0C, 0x1C, 0x0E, 0x06, 0x01, 0x00, 0x00}  // tentacle24.png
    },
    {
      {0xFE, 0x7B, 0x1F, 0x07, 0x00, 0x00, 0x00, 0x00}, // tentacle30.png
      {0x20, 0x30, 0x3F, 0x1F, 0x06, 0x00, 0x00, 0x00}, // tentacle31.png
      {0x10, 0x1C, 0x1E, 0x1F, 0x07, 0x03, 0x00, 0x00}, // tentacle32.png
      {0x18, 0x1C, 0x1E, 0x0E, 0x06, 0x03, 0x00, 0x00}, // tentacle33.png
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    },
    {
      {0x1F, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}, // tentacle40.png
      {0x1F, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}, // tentacle41.png
      {0x0F, 0x0F, 0x0E, 0x0E, 0x06, 0x02, 0x00, 0x00}, // tentacle42.png
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
      {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
    }
  };
  
  class Octopus : public Game {
    private:
      // for reading current time from internet
      typedef enum {
        SYNC_SHOW_RESET_SCREEN,
        SYNC_READ_INTERNET_TIME,
        SYNC_DELAY,
        SYNC_FINISHED
      } SyncInternetTimeStep;
  
      const bool isTimeVisibled = true;
      float showResetScreenTime;
      SyncInternetTimeStep syncInternetTimeStep;
  
      typedef enum {
        GAME_NONE,
        GAME_A,
        GAME_B
      } GameType;
  
      const Point tentaclePosition[5][5] = {
        {{45, 23}, {37, 23}, {29, 21}, { 0,  0}, { 0,  0}},
        {{45, 23}, {38, 28}, {34, 34}, {31, 39}, { 0,  0}},
        {{55, 27}, {52, 32}, {51, 35}, {51, 41}, {49, 48}},
        {{67, 34}, {68, 37}, {69, 41}, {69, 46}, { 0,  0}},
        {{84, 39}, {87, 43}, {91, 47}, { 0,  0}, { 0,  0}}
      };
  
      const uint8_t* diverStepImage[6];
      bool isDiverStepVisibled[6];
      const Point diverStepPosition[6] = {{16, 1}, {19, 18}, {21, 38}, {38, 50}, {59, 49}, {78, 50}};
  
      bool isRemainderVisibled[2];
      const Point remainderPosition[2] = {{40, 1}, {31, 1}};
  
      const uint8_t* hourDigitImage[2];
      bool isHourDigitVisibled[2];
      const Point hourDigitPosition[2] = {{60, 1}, {67, 1}};
  
      const uint8_t* minuteDigitImage[2];
      bool isMinuteDigitVisibled[2];
      const Point minuteDigitPosition[2] = {{77, 1}, {84, 1}};
  
      bool isMissDiverVisibled;
      const Point missDiverPosition = {59, 30};
  
      const uint8_t* missArmImage;
      bool isMissArmVisibled;
      const Point missArmPosition = {63, 39};
  
      const uint8_t* missLegsImage;
      bool isMissLegsVisibled;
      const Point missLegsPosition = {75, 33};
  
      const uint8_t* gameTypeImage;
      bool isGameTypeVisibled;
  
      unsigned long gameAHighScore;
      unsigned long gameBHighScore;
      static const int gameASpeed = 220;
      static const int gameBSpeed = 170;
      static const int diverSpeed = 300;
      int gameSpeed;
      unsigned long gameLoopTime;
      byte gameType;
      bool isBagVisibled;
      byte miss;
      bool isPlaying;
      byte addBonusScore;
      short secondCount;
      bool isScoreVisibled;
      byte onTheBoatCount;
      byte caught;
      byte clearMissCount;
      byte diverPosition;
      bool isJustStarted;
      bool isShowResetScreen;
      byte showHighScoreTime;
      bool isColonVisibled;
      bool isAMVisibled;
      bool isPMVisibled;
  
      bool isRandomTentacle;
      byte currentTentacle;
      bool isEndOfTentacle[5];
      byte tentacleDirection[5];
      byte tentacleCount[5];
      const byte maxTentacleCount[5] = {3, 4, 5, 4, 3};
      bool isTentacleVisibled[5][5];
      byte tentacle;
      byte diverPositionIndex;
      bool isNextTentacle;
  
      void addScore();
      void autoMove();
      void autoPlayScreen();
      void pressButton();
      void checkBonusScore();
      void checkCaught();
      void checkClearMiss();
      void checkDiver();
      void checkHighScore();
      void checkMiss();
      bool checkShowHighScoreTime();
      void checkSpeed();
      void checkTentacle();
      void gotCaught();
      void initGame();
      void moveLeft();
      void moveRight();
      void playSound(int index);
      void resetGame();
      void showGameType(byte gameTypeValue);
      void showHighScore(byte gameTypeValue);
      void showResetScreen(byte gameTypeValue = 0);
      void showScore(short value);
      void showTime();
      void startGame();
      void tryAgain();
  
    public:
      Octopus();
      bool isBackToMenuEnabled();
      void update();
      void render();
  };
  }
  
  #endif
  