예제 #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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            ResourceManager.Instance.Init(Content);
            ResourceManager.Instance.AddSprite("Overworld", "Sprites/Overworld");
            ResourceManager.Instance.AddSprite("Player", "Sprites/player");

            GraphicsManager.Instance.Init(spriteBatch);

            JsonRead jr     = new JsonRead();
            JsonData config = jr.ReadData("Data/Config.json");

            Window.Title = (string)config["windowName"];

            graphics.IsFullScreen              = (bool)config["fullscreen"];
            graphics.PreferredBackBufferWidth  = (int)config["windowWidth"];
            graphics.PreferredBackBufferHeight = (int)config["windowHeight"];
            graphics.ApplyChanges();

            states.Add(new PlayingState());
            states[currentState].game = this;
            states[currentState].Init();

            base.Initialize();
        }
        public override void Init()
        {
            world         = new World(new Vector2(0, 0.1f));
            body          = new Body(world, Vector2.Zero, 0);
            body.BodyType = BodyType.Dynamic;
            shape         = new CircleShape(0.5f, 1);
            Fixture fix = body.CreateFixture(shape);

            ConvertUnits.SetDisplayUnitToSimUnitRatio(64f);

            player = new Player();
            player.Init();
            cam = new Camera(game.GraphicsDevice.Viewport);
            GraphicsManager.Instance.cam = cam;
            JsonRead jr   = new JsonRead();
            JsonData data = jr.ReadData("Data/Map.json");

            map.Init(data);
        }