Day 62/100 100 Days of Code

Day 62/100 100 Days of Code

Rebuild Back Better

Back to working on the game! I finished my studies a bit late today and wasn't able to make much progress.I added an audio file to the project and updated the CMake file to include it in the Resources folder.

file(GLOB MENU_LIGHT_UP_SOUND "audio/Menu Light Up/Menu Light Up.wav")

    add_executable(${PROJECT_NAME} MACOSX_BUNDLE
                ./src/main.cpp ./src/game.h 
                ./src/game.cpp ./src/gameobjects.h 
                ./src/player.h ./src/thief.h 
                ./src/gatherer.h ./src/fighter.h
                ./src/menuoptionsstructure.h ./src/audioplayer.h
                ${FONT_SOURCES} ${MENU_LIGHT_UP_SOUND})

    # Add menu light up to the .app bundle
    file(RELATIVE_PATH GET_REL_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${MENU_LIGHT_UP_SOUND} )
    get_filename_component(FILE_PATH "${GET_REL_PATH}" DIRECTORY)
    set_property(SOURCE "${MENU_LIGHT_UP_SOUND}" PROPERTY MACOSX_PACKAGE_LOCATION "Resources/${FILE_PATH}")

I began working on the audio player object and chose to use a variadic template because I need three arguments for sound effects and two arguments for background music.

// Read more on audio
// https://wiki.libsdl.org/SDL3_mixer/CategoryAPI
template<typename T, typename... Types>
class AudioPlayer
{
    T* audio_file;

public:
    AudioPlayer(std::string fileLocation);
    void PlayAudio(Types... types);

private:
    ~AudioPlayer();
};