Exemplo n.º 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Initialize level
            Texture2D[,] tiles = new Texture2D[2, 2];
            tiles[0, 0] = Content.Load<Texture2D>("t1");
            tiles[0, 1] = Content.Load<Texture2D>("t2");
            tiles[1, 0] = Content.Load<Texture2D>("t3");
            tiles[1, 1] = Content.Load<Texture2D>("t4");

            level = new LevelObs(tiles, LoadObstacles());

            //Initialize scene
            camera = new Camera(Vector2.Zero, new Size(800, 600));
            scene = new Scene(this, spriteBatch, level, camera);
            Components.Add(scene);

            //Temporary sprite shapeset
            Polygon shape =
                new Polygon(new Vector2[] { new Vector2(5, 38),
                                            new Vector2(24, 38),
                                            new Vector2(26, 48),
                                            new Vector2(1, 48)});

            List<Polygon> shapeSet = new List<Xebab.Helpers.Polygons.Polygon>(1);
            shapeSet.Add(shape);

            //Initialize sprite
            Texture2D spritesheet = Content.Load<Texture2D>("guy01");
            sprite = new AnimatedSprite(scene.ContentHandler, shapeSet,
                spritesheet, new Size(31, 48));
            scene.ContentHandler.SpriteHandler.SpawnSprite(sprite);
            sprite.Position = new Vector2(300);
            sprite.AddBehavior(new CameraFollowerBehavior(sprite, camera, level));
        }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            // Load crosshair
            crosshair = Content.Load<Texture2D>("crosshair");
            crosshairCenter = new Vector2(crosshair.Width / 2, crosshair.Height / 2);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Initialize level
            Texture2D[,] tiles = new Texture2D[2, 2];
            tiles[0, 0] = Content.Load<Texture2D>("t1");
            tiles[0, 1] = Content.Load<Texture2D>("t2");
            tiles[1, 0] = Content.Load<Texture2D>("t3");
            tiles[1, 1] = Content.Load<Texture2D>("t4");
            level = new Level(tiles);

            //Initialize scene
            camera = new Camera(Vector2.Zero,
                new Size(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
            scene = new Scene(this, spriteBatch, level, camera);
            Components.Add(scene);
        }