Example #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            graphics.PreferredBackBufferWidth  = 800;
            graphics.PreferredBackBufferHeight = 600;
            RasterizerState customState = new RasterizerState();

            graphics.GraphicsDevice.RasterizerState = customState;

            graphics.ApplyChanges();

            ComponentRecord.RegisterAttribute <Sprite>("Sprite");
            ComponentRecord.RegisterAttribute <AnimatedSprite>("AnimatedSprite");
            ComponentRecord.RegisterAttribute <Transform>("Transform");
            ComponentRecord.RegisterAttribute <GUIButton>("GUIButton");
            ComponentRecord.RegisterAttribute <GUILabel>("GUILabel");
            ComponentRecord.RegisterAttribute <GUITextBox>("GUITextBox");
            ComponentRecord.RegisterAttribute <GUIImage>("GUIImage");
            ComponentRecord.RegisterAttribute <AABBCollider>("AABBCollider");
            ComponentRecord.RegisterAttribute <SATCollider>("SATCollider");
            ComponentRecord.RegisterAttribute <CharacterController>("CharacterController");

            Debug.InitializeDebug(GraphicsDevice, this);
            DebugConsole.DebugConsoleInit(this, graphics);
            GameSerializer.Init(this);
            GameScript.InitGameScript();
            Transform.UpdateGraphicsSize(graphics);
            InputManager.InitInputManager(this);
            Camera.InitCamera(graphics);
            GUILabel.Initialize(this);

            Exiting += new EventHandler <EventArgs>((object obj, EventArgs args) =>
            {
                Debug.CloseDebug();
            });

            DebugConsole.RegisterCommand("reset", (string[] args) =>
            {
                reset();
            });

            w = new World();

            this.IsMouseVisible = true;

            base.Initialize();
        }