본문 바로가기

카테고리 없음

[TIL] 고난의 연속

반응형

오늘은 필수기능을 반드시 다 완성하리라 라는 마음가짐으로 아침부터 작업을 시작했다.. 사실 오전에 코드카타를 해야하는데 요며칠 작업에 시달려서 제대로 하지도 못했다.. 내일은 꼭 하도록 하겠다.


 

 

 

트러블 슈팅

 

1. 클라이언트 부분의 아이템 관련 코드 수정중 아이템 속도가 너무 빨라져 유저 쪽으로 날아오는 느낌이 들게끔 바뀜

 

    //기존코드
    update(speed, gameSpeed, deltaTime, scaleRatio) {
        this.x -= speed * gameSpeed * deltaTime * scaleRatio;
    }
    
    //수정된 코드
        update(speed, gameSpeed, deltaTime, scaleRatio) {
                // 속도를 조절하는 방법 - 속도 계수 추가
        const speedMultiplier = 0.5; // 0.5배 속도
        this.x -= gameSpeed * deltaTime * scaleRatio * speedMultiplier;
    }

 

속도계수를 따로 추가하여 속도를 조절할 수 있게 수정하였음.

 

 

2. 스테이지 변경 검증 구간에서 실패 로그 발생

 

 

 

//  시간 기반 검증
    const currentTime = Date.now();
    const lastStageTime = currentStages[currentStages.length - 1].timestamp;
    const timeDiff = (currentTime - lastStageTime) / 1000; // 초 단위

    // 최소 필요 시간 계산 (점수 차이 / 현재 스테이지의 scorePerSecond)
    const requiredScore = targetStageData.score - currentStageData.score;
    const minRequiredTime = requiredScore / currentStageData.scorePerSecond;

    // 허용 오차 범위 (예: 5초)
    if (timeDiff < minRequiredTime - 5) {
        return { status: 'fail', message: 'Invalid stage transition time' };
    }

 

기존 코드에서 아이템에 관련한 점수를 제외하고 시간으로 바뀌는 점수에 대해서만 검증, 허용 범위를 10초로 늘렸음

 

// 5. 시간 기반 검증 (아이템 점수 제외)
    const currentTime = Date.now();
    const lastStageTime = currentStages[currentStages.length - 1].timestamp;
    const timeDiff = (currentTime - lastStageTime) / 1000; // 초 단위

    // 기본 점수만으로 필요한 시간 계산
    const baseScorePerSecond = currentStageData.scorePerSecond;
    const baseScoreDiff = targetStageData.score - currentStageData.score;
    const minRequiredTime = baseScoreDiff / baseScorePerSecond;

    // 허용 오차 범위 (5초)를 더 넓게 설정 (예: 10초)
    if (timeDiff < minRequiredTime - 10) {
        console.log('Time validation:', {
            timeDiff,
            minRequiredTime,
            baseScoreDiff,
            baseScorePerSecond
        });
        return { status: 'fail', message: 'Invalid stage transition time' };

 

 

반응형