Initial engine repository

This commit is contained in:
2026-06-08 19:58:35 +08:00
commit 7a925c3736
137 changed files with 162421 additions and 0 deletions
@@ -0,0 +1,63 @@
#pragma once
#include <frostbite2D/types/type_alias.h>
#include <string>
namespace frostbite2D {
/**
* @brief 音频系统配置
*/
struct AudioConfig {
int frequency = 44100;
uint16_t format = 0x8010;
int channels = 2;
int chunksize = 4096;
int maxSoundChannels = 32;
};
/**
* @brief 音频系统(单例)
*
* 负责初始化和管理整个音频系统,包括音量控制和声道管理。
*/
class AudioSystem {
public:
static AudioSystem& get();
AudioSystem(const AudioSystem&) = delete;
AudioSystem& operator=(const AudioSystem&) = delete;
bool init(const AudioConfig& config = AudioConfig());
void shutdown();
bool isInitialized() const { return initialized_; }
void setMasterVolume(float volume);
float getMasterVolume() const;
void setSoundVolume(float volume);
float getSoundVolume() const;
void setMusicVolume(float volume);
float getMusicVolume() const;
void pauseAllSounds();
void resumeAllSounds();
void stopAllSounds();
int getMaxChannels() const { return maxChannels_; }
private:
AudioSystem() = default;
// ~AudioSystem() 在 shutdown() 中手动调用销毁
void updateVolumes();
bool initialized_ = false;
float masterVolume_ = 1.0f;
float soundVolume_ = 1.0f;
float musicVolume_ = 1.0f;
int maxChannels_ = 32;
};
}