public static Engine Create(EngineOptions options, IController controller, IEventsCycle eventsCycle, ISceneRenderer sceneRenderer) { if (SDL_Init(SDL_INIT_VIDEO) < 0) { throw new InvalidOperationException($"Cant initialize SDL2: {SDL_GetError()}"); } if (SDL_image.IMG_Init(SDL_image.IMG_InitFlags.IMG_INIT_JPG | SDL_image.IMG_InitFlags.IMG_INIT_PNG) < 0) { throw new InvalidOperationException($"Cant initialize SDL_image: {SDL_GetError()}"); } if (SDL_ttf.TTF_Init() < 0) { throw new InvalidOperationException($"TTF_Init: {SDL_GetError()}"); } if (SDL_ShowCursor(0) < 0) { throw new InvalidOperationException($"Cant disable cursor: {SDL_GetError()}"); } if (SDL_mixer.Mix_Init( SDL_mixer.MIX_InitFlags.MIX_INIT_MP3 | SDL_mixer.MIX_InitFlags.MIX_INIT_MID | SDL_mixer.MIX_InitFlags.MIX_INIT_MOD | SDL_mixer.MIX_InitFlags.MIX_INIT_OGG | SDL_mixer.MIX_InitFlags.MIX_INIT_FLAC | SDL_mixer.MIX_InitFlags.MIX_INIT_OPUS) < 0) { throw new InvalidOperationException($"MixInit: {SDL_GetError()}"); } if (SDL_mixer.Mix_OpenAudio(22050, SDL_mixer.MIX_DEFAULT_FORMAT, 2, 4096) < 0) { throw new InvalidOperationException($"OpenAudio: {SDL_GetError()}"); } if (SDL_mixer.Mix_AllocateChannels(16) < 0) { throw new InvalidOperationException($"Cant allocate channels: {SDL_GetError()}"); } if (SDL_mixer.Mix_Volume(-1, 64) < 0) { throw new InvalidOperationException($"Min_Volume: {SDL_GetError()}"); } var screen = Ui.Screen.Create(options.WindowTitle, options.ScreenHeight, options.ScreenWidth, options.FullScreen); var miniMapRenderer = new MiniMapRenderer(); var statusBarHeight = screen.Height / 8; var statusBarWidth = screen.Width; var statusBarSprite = Sprite.Load(UiResourcesHelper.StatusBarSpritePath); var bowSprite = Sprite.Load(UiResourcesHelper.BowMiniSpritePath); var frameSprite = Sprite.Load(UiResourcesHelper.FrameSpritePath); var crossSprite = options.CrossSpritePath == null ? null : Sprite.Load(options.CrossSpritePath); var arrowSprite = Sprite.Load(UiResourcesHelper.ArrowSpritePath); var swordSprite = Sprite.Load(UiResourcesHelper.SwordSpritePath); var fireBallSprite = Sprite.Load(UiResourcesHelper.FireBallSpritePath); var shockBallSprite = Sprite.Load(UiResourcesHelper.ShockBallSpritePath); var faceSprite = Sprite.Load(UiResourcesHelper.FaceSprintPath); var faceHurtedSprite = Sprite.Load(UiResourcesHelper.FaceHurtedSpritePath); var faceBadSprite = Sprite.Load(UiResourcesHelper.FaceBadSpritePath); var logTextRenderer = TextRenderer.Load(options.FontPath, screen.Height / 50); var notesTextRenderer = TextRenderer.Load(options.FontPath, screen.Height / 50); var statusTextRenderer = TextRenderer.Load(options.FontPath, screen.Height / 20); var notesRenderer = new NotesRenderer(Sprite.Load(options.NotesSpritePath), notesTextRenderer, statusBarHeight); var monologueTextRenderer = TextRenderer.Load(options.FontPath, screen.Height / 50); var monologueRenderer = new MonologueRenderer(monologueTextRenderer, statusBarHeight); var statusBarRenderer = new StatusRenderer( statusBarSprite, crossSprite, statusBarHeight, logTextRenderer, notesRenderer, monologueRenderer, bowSprite, swordSprite, frameSprite, statusTextRenderer, arrowSprite, fireBallSprite, shockBallSprite, faceSprite, faceHurtedSprite, faceBadSprite); var textRenderer = options.FontPath == null ? null : TextRenderer.Load(options.FontPath, 24); return(new Engine(screen, controller, eventsCycle, sceneRenderer, miniMapRenderer, statusBarRenderer, textRenderer)); }
internal static void ReglerVolumeSon(String son, int volume) { SDL_mixer.Mix_Volume(sons.Keys.ToList().IndexOf(son), volume); }
protected override void SetSoundVolume(int volume) { SDL_mixer.Mix_Volume(-1, volume); }