public Player(Animation playerAnimation, Vector2 playerPosition, SoundEffect jump, SoundEffect sword, Texture2D swordTexture) { this.PlayerAnimation = playerAnimation; this.Position = playerPosition; this.Velocity = new Vector2(0, 0); this.MaxVelocity = new Vector2(10, 15); this.Acceleration = new Vector2(0.5f, 0); this.Decceleration = new Vector2(0.5f, 0); this.Friction = new Vector2(0.5f, 0); this.Gravity = 0.75f; this.PlayerRect = new Rectangle((int)this.Position.X + 18, (int)this.Position.Y, 54, 99); this.OnGround = false; this.CanJump = true; this.JumpNow = false; this.CanFall = true; this.CanMove = true; this.Spring = false; this.InWater = false; this.IsKnockBack = false; this.IsHitBelow = false; this.IsOverDoor = false; this.Sword = new Weapon(swordTexture, Position.X-18, Position.Y); this.JumpSound = jump; this.SwordSound = sword; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); PlayerTexture = Content.Load<Texture2D>("Textures/player"); MapTexture = Content.Load<Texture2D>("Textures/tiles"); EnemyTexture = Content.Load<Texture2D>("Textures/enemySheet"); DoorTexture = Content.Load<Texture2D>("Textures/door"); TextureSword = Content.Load<Texture2D>("Textures/sword"); BossTexture = Content.Load<Texture2D>("Textures/bossSheet"); Background = Content.Load<Texture2D>("Textures/background"); Song walkingSong = Content.Load<Song>("Audio/walking_flat"); SoundEffect jumpSfx = Content.Load<SoundEffect>("Audio/jump"); SoundEffect swordSfx = Content.Load<SoundEffect>("Audio/sword"); MediaPlayer.IsRepeating = true; MediaPlayer.Play(walkingSong); Animation playerAnimation = new Animation(PlayerTexture, Vector2.Zero, 90, 99, 3, 100, Color.White, 1f, true, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height); player = new Player(playerAnimation, new Vector2(96 * 4, 96 * 3), jumpSfx, swordSfx, TextureSword); // Load Level Data levelData = new LevelData(); LevelChunkObjects = levelData.getLevel(MapTexture, EnemyTexture, BossTexture, DoorTexture, CurrentLevel); // Create a Blank white image WhiteRectangle = new Texture2D(GraphicsDevice, 1, 1); WhiteRectangle.SetData(new[] { Color.White }); }