Beispiel #1
0
 public Room_About()
     : base()
 {     
     lineTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(Program.VIDEO.fontPath, 10));
     lineTextSprite.BackgroundColor = Color.Black;
     Items.Add(new MenuItem_BackToMainMenu());
 }
Beispiel #2
0
 protected virtual void InitializeDrawing()
 {
     titleTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(Program.VIDEO.fontPath, 15));
     titleTextSprite.BackgroundColor = Color.Black;
     itemTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(Program.VIDEO.fontPath, 10));
     itemTextSprite.BackgroundColor = Color.Black;
     optionTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(Program.VIDEO.fontPath, 10));
     optionTextSprite.BackgroundColor = Color.Black;
 }
Beispiel #3
0
        void Run()
        {
            SdlDotNet.Input.Mouse.ShowCursor = false;
            Video.WindowIcon(System.Reflection.Assembly.GetExecutingAssembly());
            Video.WindowCaption = "FlurrySharp Test Window";
            g_nMonitors = Win32.User.GetSystemMetrics(Win32.User.SM_CMONITORS);

            screen = Video.SetVideoMode(Win32.User.GetSystemMetrics(Win32.User.SM_CXVIRTUALSCREEN), Win32.User.GetSystemMetrics(Win32.User.SM_CYVIRTUALSCREEN), true, true, false, true, false);
            Win32.User.SetWindowPos(Video.WindowHandle, new IntPtr(0), 0, 0, screen.Width, screen.Height, 0);

            txtSprite = new TextSprite(new SdlDotNet.Graphics.Font("vera.ttf", 12));
            settings = new FlurrySettings();

            Events.Tick += new EventHandler<TickEventArgs>(Events_Tick);
            Events.VideoResize += new EventHandler<VideoResizeEventArgs>(Events_VideoResize);
            Events.Quit += new EventHandler<QuitEventArgs>(Events_Quit);
            Events.Fps = Types.iMaxFrameProgressInMs;
            Events.MouseMotion += new EventHandler<SdlDotNet.Input.MouseMotionEventArgs>(Events_MouseMotion);
            Events.KeyboardDown += new EventHandler<SdlDotNet.Input.KeyboardEventArgs>(Events_KeyboardDown);
            Init();
            Reshape();

            Events.Run();
        }
Beispiel #4
0
        private void Go()
        {
            if (File.Exists(fileName))
            {
                filePath = "";
                fileDirectory = "";
            }
            else if (File.Exists(Path.Combine(fileDirectory, fileName)))
            {
                filePath = "";
            }

            string file = Path.Combine(Path.Combine(filePath, fileDirectory), fileName);

            textDisplay = new TextSprite(" ", new SdlDotNet.Graphics.Font(file, 20), Color.Red);
            Video.WindowIcon();
            Video.WindowCaption = "SDL.NET - StreamingAudio";
            screen = Video.SetVideoMode(width, height);

            switch (streamChoice)
            {
                case StreamChoice.InternalCallback:
                    stream = new AudioStream(playbackFreq, AudioFormat.Unsigned16Little, SoundChannel.Mono, samples);
                    buffer16 = new short[samples];
                    break;
                case StreamChoice.CustomCallback:
                    callback = new AudioCallback(Unsigned16LittleCallback);
                    stream = new AudioStream(playbackFreq, AudioFormat.Unsigned16Little, SoundChannel.Mono, samples, callback, "Hello World");
                    buffer16 = new short[samples];
                    break;
                case StreamChoice.CustomCallback8Bit:
                    callback = new AudioCallback(Unsigned8Callback);
                    stream = new AudioStream(playbackFreq, AudioFormat.Unsigned8, SoundChannel.Mono, samples, new AudioCallback(Unsigned8Callback), "Hello World");
                    buffer8 = new byte[samples];
                    break;
                default:
                    stream = new AudioStream(playbackFreq, AudioFormat.Unsigned16Little, SoundChannel.Mono, samples);
                    buffer16 = new short[samples];
                    break;
            }

            offset = stream.Offset;
            volume = 0.9 * 32768;

            buffer16 = new short[samples];

            osc.Rate = 20;
            osc.Amplitude = 1;

            osc2.Rate = 3;
            osc2.Amplitude = 10;

            stream.Paused = false;
            textDisplay.Text = SdlDotNetExamplesBrowser.StringManager.GetString(
                        "StreamingAudioDirections", CultureInfo.CurrentUICulture);
            textDisplay.TextWidth = 350;
            Events.Run();
        }
Beispiel #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (this.textDisplay != null)
             {
                 this.textDisplay.Dispose();
                 this.textDisplay = null;
             }
             if (this.stream != null)
             {
                 this.stream.Dispose();
                 this.stream = null;
             }
         }
         this.disposed = true;
     }
 }
Beispiel #6
0
        public void Go()
        {
            // Load the music and sounds.
            music["mason2"] = new Music(Path.Combine(Path.Combine(filePath, fileDirectory), "mason2.mid"));
            music["fard-two"] = new Music(Path.Combine(Path.Combine(filePath, fileDirectory), "fard-two.ogg"));
            boing = new Sound(Path.Combine(Path.Combine(filePath, fileDirectory), "boing.wav"));

            textDisplay = new TextSprite(" ", new SdlDotNet.Graphics.Font(Path.Combine(Path.Combine(filePath, fileDirectory), "FreeSans.ttf"), 20), Color.Red);

            // Start up SDL
            Video.WindowIcon();
            Video.WindowCaption = "SDL.NET - AudioExample";
            screen = Video.SetVideoMode(width, height);

            // Play the music and setup the queues.
            music["mason2"].Play();
            //music["fard-two"].Play();

            // Set up the music queue and start it
            music["mason2"].QueuedMusic = music["fard-two"];
            music["fard-two"].QueuedMusic = music["mason2"];
            MusicPlayer.EnableMusicFinishedCallback();

            // Begin the SDL ticker
            Events.Fps = 50;

            textDisplay.Text = SdlDotNetExamplesBrowser.StringManager.GetString(
                        "AudioExampleDirections", CultureInfo.CurrentUICulture);
            textDisplay.TextWidth = 200;
            Events.Run();
        }
Beispiel #7
0
        public SDLVideo(TVSystem system)
        {
            LoadSettings();
            initialized = false;
            canRender = false;
            Console.WriteLine("->Initializing video ...");
            fontPath = System.IO.Path.Combine(Program.ApplicationFolder, "FreeSans.ttf");
            // Initialize the video
            Video.Initialize();
            Video.WindowIcon();
            Video.WindowCaption = "My Nes SDL";
            fullscreenModes = Video.ListModes();
            Video.GLDoubleBufferEnabled = !ImmediateMode;
            windowW = 256 * stretchMultiply;
            switch (system)
            {
                case TVSystem.NTSC:
                    {
                        Events.TargetFps = 60;
                        break;
                    }
                case TVSystem.PALB:
                case TVSystem.DENDY:	
                    {
                        Events.TargetFps = 50;
                        break;
                    }
            }
            if (cutLines)
            {
                if (system == TVSystem.NTSC)
                {
                    scanlines = 224;
                    firstToCut = 8;
                }
                else
                {
                    scanlines = 238;
                    firstToCut = 1;
                }
            }
            else
            {
                scanlines = 240;
                firstToCut = 0;
            }
            screenBufferSize = 256 * scanlines;
            originalRect = new Rectangle(0, 0, 256, scanlines);
            screen_back = new Surface(256, scanlines, 32);

            windowH = scanlines * stretchMultiply;

            pointer = screen_back.Pixels;
            screen_pointer = (int*)screen_back.Pixels;
            NesEmu.SetupVideoRenderer(this, true, screen_back.Pixels, firstToCut * 256, 256 * (240 - firstToCut));
            // Create texts
            Console.WriteLine("-->Loading fonts ...");
            fpsTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            fpsTextSprite.Color = Color.White;
            fpsTextSprite.BackgroundColor = Color.Black;
            notTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            notTextSprite.BackgroundColor = Color.Black;
            soundRecordTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            soundRecordTextSprite.BackgroundColor = Color.Black;
            statusTextSprite = new TextSprite(new SdlDotNet.Graphics.Font(fontPath, 15));
            statusTextSprite.BackgroundColor = Color.Black;
            // set video mode.
            Resize(FullScreen, true, windowW, windowH);
            Events.VideoResize += VideoResize;
            Events.MouseButtonDown += Events_MouseButtonDown;
            Events.MouseButtonUp += Events_MouseButtonUp;
            Events.Tick += OnTick;
            canRender = true;
            initialized = true;
            Console.WriteLine("->Video initialized successfully");
        }
        /// <summary>
        /// Event handler for tick events
        /// </summary>
        /// <param name="sender">Sender of the event</param>
        /// <param name="e">Parameters of the event</param>
        private void Events_Tick(object sender, TickEventArgs e)
        {
            // Clear the screen, draw the hero and output to the window
            Video.Screen.Fill(Color.DarkGreen);
            Video.Screen.Blit(this.context.BackGround);

            // Add a victory area, should be tall as 50% of screen and large as 5% of screen
            Video.Screen.Blit(
                this.context.VictoryArea,
                this.context.VictoryArea.UpperLeft);

            try
            {
                foreach (Character hero in this.context.Characters)
                {
                    Video.Screen.Blit(hero);
                }
            }
            catch (System.ArgumentOutOfRangeException ex)
            {
                Console.WriteLine(ex.StackTrace.ToString());
            }

            // Check winning Condition
            SDL.Sheep[] sheeps = Array.ConvertAll(
                Array.FindAll(
                    this.context.Characters.ToArray(),
                    delegate(Character toCheck)
                    {
                        return toCheck.GetType().Equals(typeof(SDL.Sheep));
                    }),
                delegate(Character target)
                {
                    return target as Sheep;
                });

            TextSprite timerText = new TextSprite(string.Format("{0:00}'{1:00}''", Math.Floor(this.timer.Elapsed.TotalMinutes), this.timer.Elapsed.Seconds), new SdlDotNet.Graphics.Font(System.IO.Path.Combine(@"Graphics\Ttf", "comicbd.ttf"), 14), Color.GhostWhite);
            Video.Screen.Blit(
                    timerText,
                    new Point(1, 1));

            if (Array.TrueForAll(
                sheeps,
                delegate(Sheep toCheck)
                {
                    return toCheck.Safe;
                }))
            {
                this.timer.Stop();
                TextSprite victoryText = new TextSprite("Victory !", new SdlDotNet.Graphics.Font(System.IO.Path.Combine(@"Graphics\Ttf", "comicbd.ttf"), 32), Color.GhostWhite);
                TextSprite resumeOfVictory = new TextSprite(
                    string.Format(
                        "It tooks you {0} minutes and {1} seconds to store your sheep",
                        Math.Floor(this.timer.Elapsed.TotalMinutes),
                        this.timer.Elapsed.Seconds),
                    new SdlDotNet.Graphics.Font(
                        System.IO.Path.Combine(@"Graphics\Ttf", "comicbd.ttf"),
                        16),
                    Color.GhostWhite);
                Video.Screen.Blit(
                    victoryText,
                    new Point(
                        (Video.Screen.Width - victoryText.Width) / 2,
                        (Video.Screen.Height - victoryText.Height - resumeOfVictory.Height) / 2));
                Video.Screen.Blit(
                    resumeOfVictory,
                    new Point(
                        (Video.Screen.Width - resumeOfVictory.Width) / 2,
                        ((Video.Screen.Height - victoryText.Height - resumeOfVictory.Height) / 2) + victoryText.Height));
            }

            Video.Screen.Update();

            this.MoveCharacters();
        }