예제 #1
0
        public GameClass()
        {
            Game = this;

            graphics = new GraphicsDeviceManager(this);

            Window.Title = "We Are Legion";

            if (Program.Width < 0 || Program.Height < 0)
            {
                LoadConfig();
            }
            else
            {
                var config = new Config();
                config.Width      = Program.Width;
                config.Height     = Program.Height;
                config.Fullscreen = false;

                CurrentConfig = config;
            }

            graphics.IsFullScreen              = false;
            graphics.PreferredBackBufferWidth  = CurrentConfig.Width;
            graphics.PreferredBackBufferHeight = CurrentConfig.Height;
            graphics.ApplyChanges();
            ApplyConfig(Activate: false);

            if (Program.MaxFps)
            {
                graphics.SynchronizeWithVerticalRetrace = false;
                IsFixedTimeStep = false;
            }
            else
            {
                graphics.SynchronizeWithVerticalRetrace = !UnlimitedSpeed;
                IsFixedTimeStep = !UnlimitedSpeed;
            }

            if (Program.Headless)
            {
                graphics.PreferredBackBufferWidth  = 1;
                graphics.PreferredBackBufferHeight = 1;
            }

            Content.RootDirectory = "Content";
        }
예제 #2
0
        public App()
        {
            //SDL is comprised of 8 subsystems. Here we initialize the video
            if (Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO) < 0)
            {
                Console.WriteLine("Error initializing SDL");
                Sdl.SDL_Quit();
                return;
            }

            /* Rather than set the video properties up in the constructor, I set
             * them in setVideo. The reason for this is that 2 pointers are used
             * to interact with SDL structures. Once used they convert their
             * handles into vidInfo and surface tamer variables. That this
             * occurs inside the function means the pointers will release
             * their memory on function exit.
             */
            setSDLVideo();

            /* openGL is not part of SDL, rather it runs in a window handled
             * by SDL. here we set up some openGL state
             */
            //initialize game
            game = new GameClass();

            /* finP is the property get/setter for the boolean fin in the game
             * class. It is held in the game class because the game class handles
             * events. When escape is pressed, fin is set to true and the following
             * loop
             * terminates.
             * The function tick is called every loop. It is passed the time
             * taken for each loop
             */
            while (!game.finP)
            {
                game.pollEvents();
                Tick();           //updates the game object
                Sdl.SDL_Delay(1); //release the thread
            }

            /* When the loop ends the code drops down to here. SDL_Quit shuts
             * down the SDL subsystems initialized by SDL_Init
             */
            Sdl.SDL_Quit();
            return;
        }
예제 #3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args_)
        {
            Console.WriteLine("Starting up application.");

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            string args = null;

#if DEBUG
            if (args_.Length == 0)
            {
                // Demo debug
                args = "--server                --port 13000 --p 1 --t 1234 --n 1 --debug --w 1280 --h 720";

                // Demo release
                //args = "--w 1920 --h 1080";

                // Client
                //args = "--client --ip 173.174.83.72 --port 13000 --p 1 --t 1234 --n 2 --map Beset.m3n   --w 1280 --h 720 --debug";

                // Local client
                //args = "--client --ip 127.0.0.1 --port 13000 --p 1 --t 1234 --n 2 --map Beset.m3n   --debug --double";

                // Single player windowed
                //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n   --debug --w 1280 --h 720";
                //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n   --debug --w 1920 --h 1080";

                // Single player debug
                //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n   --debug --double";

                // Single player
                //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n";

                // Single player with client-server debug
                //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n   --debug --double --logshorthash";

                // Two player debug
                //var clientArgs = "--client --ip 127.0.0.1 --port 13000 --p 1 --t 1234 --n 2 --map Beset.m3n   --debug --double --logshorthash --logperiod 10";
                //var serverArgs = "--server                --port 13000 --p 2 --t 1234 --n 2 --map Beset.m3n   --debug --double --logshorthash --logperiod 10";
                //args = serverArgs;
                //Start(clientArgs);

                // Four player debug
                //args = "--server                --port 13000 --p 1 --t 1234 --n 4 --map Beset.m3n   --debug --quad";
                //Start("  --client --ip 127.0.0.1 --port 13000 --p 2 --t 1234 --n 4 --map Beset.m3n   --debug --quad");
                //Start("  --client --ip 127.0.0.1 --port 13000 --p 3 --t 1234 --n 4 --map Beset.m3n   --debug --quad");
                //Start("  --client --ip 127.0.0.1 --port 13000 --p 4 --t 1234 --n 4 --map Beset.m3n   --debug --quad");
            }
#else
            // Release
            args = "";

            //args = "--server                --port 13000 --p 1 --t 1234 --n 1 --w -1";
            //args = "--server                --port 13000 --p 1 --t 1234 --n 1 --w 1280 --h 720";

            //args = "--server                --port 13000 --p 1 --t 1234 --n 1 --map Beset.m3n";
            //args = "--server                --port 13000 --p 2 --t 1234 --n 1 --map Beset.m3n   --debug --double";
#endif

            if (args != null)
            {
                ParseOptions(args);
            }
            else
            {
                ParseOptions(new List <string>(args_));
            }

            using (GameClass game = new GameClass())
            {
                game.Run();
            }
        }