내일배움캠프 5주차 3일차 TIL

김재혁·2025년 1월 15일

오늘 한 일

  • 팀 프로젝트 진행

보스몬스터 구현

  • 원래 Character를 상속받아 아이템을 가지고 있는 몬스터를 구현하려고 했으나 그 기능을 제거해서
    그냥 Monster를 상속 받아 10레벨이 되면 보스 몬스터가 등장하게 변경.

사운드 구현

  • Window SDK를 사용해 로그 출력 시작 시 배경음이 나오도록 설정.
#include "main.h"
#include <windows.h>
#include <mmsystem.h>
#include <iostream>

#pragma comment(lib, "winmm.lib")

using namespace std;

void PlaySimpleSound() {
    const char* soundFilePath = "C:\\Users\\KimJH\\RandomTurnRpgProject\\EternalHunter\\Sound\\player.wav";

    // 경로 출력
    cout << "Sound file path: " << soundFilePath << endl;

    // 소리 재생
    if (!sndPlaySound(TEXT("C:\\Users\\KimJH\\RandomTurnRpgProject\\EternalHunter\\Sound\\player.wav"), SND_FILENAME | SND_SYNC)) {
        DWORD error = GetLastError();
        cout << "오류 " << error << endl;
    }
}

int main() {
    PlaySimpleSound();

    srand(time(NULL));

    GameManager gm;
    gm.StartGame();

    return 0;
}
  • #include <windows.h> : 윈도우 API 함수, 자료형, 매크로 등을 사용하기 위한 헤더 파일을 포함.
  • #include <mmsystem.h> :멀티미디어 시스템 함수 (예: 소리 재생 등)를 사용하기 위한 헤더 파일을 포함.
  • #pragma comment(lib, "winmm.lib") : winmm.lib 라이브러리를 사용해 지정된 경로의 .wav 파일을 동기적으로 재생하는 함수 sndPlaySound를 호출.
  • 사용하고자 하는 Wav 파일을 프로젝트 파일에 넣어서 경로를 지정하고 불러와 실행시키는 방식 사용.

0개의 댓글