Ejemplo n.º 1
0
        public Game1()
        {
            ConfigFile configFile = new ConfigFile(gameSettingsIni);

            // engine settings
            gameSpeed = configFile.SettingGroups[engineSettings].Settings["gameSpeed"].GetValueAsFloat();
            defaultResolutionHeight = configFile.SettingGroups[engineSettings].Settings["defaultResolutionHeight"].GetValueAsInt();
            enableDebugging         = configFile.SettingGroups[engineSettings].Settings["enableDebugging"].GetValueAsBool();
            this.ShowDebugView      = false;

            // video settings
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = configFile.SettingGroups[videoSettings].Settings["Fullscreen"].GetValueAsBool();
            if (graphics.IsFullScreen)
            {
                graphics.PreferredBackBufferWidth  = configFile.SettingGroups[videoSettings].Settings["Width"].GetValueAsInt();
                graphics.PreferredBackBufferHeight = configFile.SettingGroups[videoSettings].Settings["Height"].GetValueAsInt();
            }
            else
            {
                // default resolution and windowed resolution
                graphics.PreferredBackBufferWidth  = 1280;
                graphics.PreferredBackBufferHeight = 720;
            }
            SetVsync(configFile.SettingGroups[videoSettings].Settings["Vsync"].GetValueAsBool());
            graphics.ApplyChanges();

            if (enableDebugging)
            {
                Components.Add(new DebugComponent(this, Content, graphics));
            }

            Content.RootDirectory = "Content";
            physicsSystem         = new PhysicsSystem();
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            // players get updated twice as much as all other entities
            playersFixedTimeStep = new FixedTimeStepSystem(fixedTimestep, maxSteps, new SingleStep(PlayersSingleStep), new PostStepping(PlayersPostStepping));
            fixedTimeStep        = new FixedTimeStepSystem(fixedTimestep * 2f, maxSteps, new SingleStep(SingleStep), new PostStepping(PostStepping));

            // general settings
            GameVariables.NumPlayers = configFile.SettingGroups[generalSettings].Settings["NumPlayers"].GetValueAsInt();
            GameVariables.Difficulty = configFile.SettingGroups[generalSettings].Settings["Difficulty"].GetValueAsInt();
            GameVariables.Pvp        = configFile.SettingGroups[generalSettings].Settings["Pvp"].GetValueAsBool();
        }
Ejemplo n.º 2
0
        public Game1()
        {
            ConfigFile configFile = new ConfigFile(gameSettingsIni);

            // engine settings
            gameSpeed = configFile.SettingGroups[engineSettings].Settings["gameSpeed"].GetValueAsFloat();
            defaultResolutionHeight = configFile.SettingGroups[engineSettings].Settings["defaultResolutionHeight"].GetValueAsInt();
            enableDebugging = configFile.SettingGroups[engineSettings].Settings["enableDebugging"].GetValueAsBool();
            this.ShowDebugView = false;

            // video settings
            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = configFile.SettingGroups[videoSettings].Settings["Fullscreen"].GetValueAsBool();
            if (graphics.IsFullScreen)
            {
                graphics.PreferredBackBufferWidth = configFile.SettingGroups[videoSettings].Settings["Width"].GetValueAsInt();
                graphics.PreferredBackBufferHeight = configFile.SettingGroups[videoSettings].Settings["Height"].GetValueAsInt();
            }
            else
            {
                // default resolution and windowed resolution
                graphics.PreferredBackBufferWidth = 1280;
                graphics.PreferredBackBufferHeight = 720;
            }
            SetVsync(configFile.SettingGroups[videoSettings].Settings["Vsync"].GetValueAsBool());
            graphics.ApplyChanges();

            if (enableDebugging)
            {
                Components.Add(new DebugComponent(this, Content, graphics));
            }

            Content.RootDirectory = "Content";
            physicsSystem = new PhysicsSystem();
            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            // players get updated twice as much as all other entities
            playersFixedTimeStep = new FixedTimeStepSystem(fixedTimestep, maxSteps, new SingleStep(PlayersSingleStep), new PostStepping(PlayersPostStepping));
            fixedTimeStep = new FixedTimeStepSystem(fixedTimestep * 2f, maxSteps, new SingleStep(SingleStep), new PostStepping(PostStepping));

            // general settings
            GameVariables.NumPlayers = configFile.SettingGroups[generalSettings].Settings["NumPlayers"].GetValueAsInt();
            GameVariables.Difficulty = configFile.SettingGroups[generalSettings].Settings["Difficulty"].GetValueAsInt();
            GameVariables.Pvp = configFile.SettingGroups[generalSettings].Settings["Pvp"].GetValueAsBool();
        }