PIXEL_PER_METER = (30.0 / 1.0)  # 1m = 30pixel이라 정함
RUN_SPEED_KMPH = 20.0  # 시속(km / hour)
RUN_SPEED_MPM = (RUN_SPEED_KMPH * 1000.0 / 60.0)  # m / 분
RUN_SPEED_MPS = (RUN_SPEED_MPM / 60.0)  # m/s
RUN_SPEED_PPS = (RUN_SPEED_MPS * PIXEL_PER_METER)  # m/s * p/m = p/s

def handle_left_run(self, frame_time):
    distance = RUN_SPEED_PPS * frame_time
    self.x -= distance
    if not self.IsKeyDown:
        self.run_frames += frame_time
    if self.x < 0:
        self.state = self.RIGHT_RUN
        self.x = 0
    if(self.run_frames >= 2):   # 2초가 지나면
        self.state = self.LEFT_STAND
        self.stand_frames = 0

def handle_left_stand(self, frame_time):
    if not self.IsKeyDown:
        self.stand_frames += frame_time
    if self.stand_frames >= 2:
        self.state = self.LEFT_RUN
        self.run_frames = 0

def handle_right_run(self, frame_time):
    distance = RUN_SPEED_PPS * frame_time
    self.x += distance
    if not self.IsKeyDown:
        self.run_frames += frame_time
    if self.x > 800:
        self.state = self.LEFT_RUN
        self.x = 800
    if(self.run_frames >= 2):
        self.state = self.RIGHT_STAND
        self.stand_frames = 0

def handle_right_stand(self, frame_time):
    if not self.IsKeyDown:
        self.stand_frames += frame_time
    if self.stand_frames >= 2:
        self.state = self.RIGHT_RUN
        self.run_frames = 0