Пример #1
0
 public Attack(Texture2D spriteSheet, Vector2 velocity, Player attackOwner, Vector2 pos, int width, int height)
     : base(pos, width, height)
 {
     this.spriteSheet = new SpriteSheet(spriteSheet, width, height);
     this.velocity = velocity;
     this.attackOwner = attackOwner;
     tint = Color.White;
 }
Пример #2
0
 void AssignMap(int x, int y, char c)
 {
     Vector2 pos = new Vector2(x * 32 + xOff, y * 32 + yOff);
     switch (c)
     {
         case 'w':
             grid[y][x] = new Wall(wall, pos, 32, 32);
             break;
         case 'r':
             grid[y][x] = new RockWall(rockWall, pos, 32, 32);
             break;
         case 'p':
             grid[y][x] = new Player(player, pos, 32, 32);
             break;
         default:
             grid[y][x] = null;
             break;
     }
 }
Пример #3
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);
        }