 #include <Adafruit_GFX.h>
 #include <Adafruit_SSD1306.h>
 #include <avr/pgmspace.h>
+#include <TimerOne.h>
 
 #define D(x)
 

    double nextStepX = player->dirX * STEP_SIZE;
    double nextStepY = player->dirY * STEP_SIZE;

  if (pgm_read_byte(&level_map[int(player->y)][int(player->x + nextStepX)]) == 0) {
      player->x += nextStepX;
   }

  if (pgm_read_byte(&level_map[int(player->y + nextStepY)][int(player->x)]) == 0) {
      player->y += nextStepY;
   }
    // D(Serial.print("palyer x,y"));
    // D(Serial.print(player->x));
    // D(Serial.print(","));
    // D(Serial.println(player->y));
    display.clearDisplay();
    doRayCasting(player);
    display.display();
  }

  if (digitalRead(LEFT_BUTTON) == 0) {
    rotatePlayer(player, LEFT);
    display.clearDisplay();
    doRayCasting(player);
    display.display();
  }

  if (digitalRead(RIGHT_BUTTON) == 0) {
    rotatePlayer(player, RIGHT);
    display.clearDisplay();
    doRayCasting(player);
    display.display();
  }
}


  pinMode(UP_BUTTON, INPUT_PULLUP);
  pinMode(LEFT_BUTTON, INPUT_PULLUP);
  pinMode(RIGHT_BUTTON, INPUT_PULLUP);

  Timer1.initialize(50000); 
  Timer1.attachInterrupt(timer_IRQ);

  display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS);  // initialize with the I2C addr 0x3C (for the 128x64)
  display.clearDisplay();
