Esempio n. 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Map.SetTileMapper();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("tempFont");
            Texture2D dude = Content.Load<Texture2D>("PlayerSheet");
            Texture2D wall = Content.Load<Texture2D>("WallSheet");
            Texture2D rockWall = Content.Load<Texture2D>("RockWallSheet");
            Player.attackImage = Content.Load<Texture2D>("AttackSheet");
            heart = Content.Load<Texture2D>("HeartSheet");
            bGround = Content.Load<Texture2D>("Background");
            strip = Content.Load<Texture2D>("Strip");

            string[] data =
            {
                "wwwwwwwwwwwwwwwwwwwwwwww",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w                      w",
                "w      w               w",
                "w                      w",
                "wwwwwwwwwwwwwwwwwwwwwwww"
            };

            map = new Map(0, 0, data[0].Length, data.Length);
            graphics.PreferredBackBufferWidth = data[0].Length * 32;
            graphics.PreferredBackBufferHeight = data.Length * 32 + 32;
            graphics.ApplyChanges();
            map.player = dude;
            map.wall = wall;
            map.rockWall = rockWall;

            map.SetMap(data, cols);
            player1 = new Player(dude, new Vector2(32 * 3, 32 * 11), 32, 32);

            Dictionary<string, Keys> controls = new Dictionary<string, Keys>();
            controls.Add("left", Keys.A);
            controls.Add("right", Keys.D);
            controls.Add("jump", Keys.W);
            controls.Add("eat", Keys.F);
            controls.Add("attack", Keys.E);
            player1.AddControls(controls);
            player1.SetColour(new Color(170, 170, 255));

            player2 = new Player(dude, new Vector2(32 * 20, 32 * 11), 32, 32);

            controls = new Dictionary<string, Keys>();
            controls.Add("left", Keys.J);
            controls.Add("right", Keys.L);
            controls.Add("jump", Keys.I);
            controls.Add("eat", Keys.H);
            controls.Add("attack", Keys.U);
            player2.AddControls(controls);
            player2.SetColour(new Color(255, 170, 170));

            cols.Add(player1, true);
            cols.Add(player2, true);

            cols.Add(new MovingPlatform(wall, new Vector2(32 * 10, 32 * 12), 5 * 32, 32), true);

            //cols.Add(new Player(dude, new Vector2(50, 200), 32, 32), true);
            //cols.Add(new Wall(wall, new Vector2(50, 250), 32, 32), false);
            //cols.Add(new RockWall(rockWall, new Vector2(70, 228), 32, 32), false);
        }