Exemple #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            if (_gameCamera == null)
            {
                _gameCamera = new Camera2D(_graphics.GraphicsDevice.Viewport);
            }
            GraphicsDevice.Clear(Color.LightSkyBlue);

            Plane y_plane = new Plane(-1 * Vector3.UnitY, _graphics.GraphicsDevice.Viewport.Height / 2);
            //Plane y_plane = new Plane(Vector3.UnitY, (float)-gameTime.TotalGameTime.TotalSeconds);
            _gameCamera.Center = theDude.BoundingBox.Center;

            //spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Matrix.Identity);
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, _gameCamera.ViewMatrix);
            _theGrid.Draw(spriteBatch);
            theDude.Draw(spriteBatch);
            spriteBatch.DrawString(font,"Test", Vector2.Zero, Color.Maroon);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            if (_gameCamera == null)
            {
                _gameCamera = new Camera2D(_graphics.GraphicsDevice.Viewport);
            }
            Texture2D theDudeTexture;
            theDudeTexture = Content.Load<Texture2D>("dude");

            font = Content.Load<SpriteFont>("SpriteFont1");

            CustomWorldData worldData = new CustomWorldData("Examplia");
            worldData.LoadContent(Content);

            itemCatalog = new ItemCatalog(worldData._itemData);

            if (System.IO.File.Exists("C:\\Users\\Public\\MyLevel.lvl") == true)
            {

                    try
                    {
                        _theGrid = new CollisionGrid("C:\\Users\\Public\\MyLevel.lvl", Content.Load<Texture2D>("Active"), Content.Load<Texture2D>("Inactive"), Content.Load<Texture2D>("Platform"));
                    }
                    catch //err as F
                    {
                        _theGrid = new CollisionGrid(100, 100);
                    }

            }
            else
            {
                _theGrid = new CollisionGrid(100, 100);
            }

            theDude = new Player(theDudeTexture, Vector2.Zero);
            theDude.TempAddItem(itemCatalog.GetItem(2));
            theDude.TempAddItem(itemCatalog.GetItem(1));

            // TODO: use this.Content to load your game content here
        }