/// <summary> /// The parameterized constructor for the player class /// </summary> /// <param name="pTexture">The texture that the player will use</param> /// <param name="g">The GraphicsDeviceManager that will be used</param> public Player(Texture2D pTexture, GraphicsDeviceManager gdm, World w, Texture2D fTexture) { //Load the texture and set the vectors graphic = gdm; screenWidth = gdm.PreferredBackBufferWidth; screenHeight = gdm.PreferredBackBufferHeight; position = new Vector2(150, 50); body = new Rectangle((int)position.X, (int)position.Y, 50, 50); //TODO: add content manager burning = w.game.Content.Load<SoundEffect>("Audio/WAVs/fire"); burning2 = burning.CreateInstance(); texture = pTexture; flameTexture = fTexture; velocity = new Vector2(0, 0); world = w; world.Player = this; //Set the player state hState = HorizontalState.standing; //Make an array of three torches torches = new Torch[999]; for (int i = 0; i < torches.Length; i++) { torches[i] = new Torch(this, fTexture, w); } }
//Constructor public Torch(Player p, Texture2D f, World w) { player = p; position = p.Location; velocity = new Vector2(0, 0); bounds = new Rectangle((int)position.X, (int)position.Y, 20, 50); flame = f; world = w; }
/// <summary> /// The parameterized constructor for the player class /// </summary> /// <param name="pTexture">The texture that the player will use</param> /// <param name="g">The GraphicsDeviceManager that will be used</param> public Player(Texture2D pTexture, GraphicsDeviceManager gdm, World w) { //Load the texture and set the vectors graphic = gdm; screenWidth = gdm.PreferredBackBufferWidth; screenHeight = gdm.PreferredBackBufferHeight; position = new Vector2(screenWidth / 2, screenHeight / 2); body = new Rectangle((int)position.X, (int)position.Y, screenWidth, screenHeight); texture = pTexture; velocity = new Vector2(0, 0); world = w; //Set the player state hState = HorizontalState.standing; }
/// <summary> /// Constructor /// </summary> /// <param name="c">Content Manager</param> /// <param name="b">Bounding Rectangle - Displays the menu of set size</param> public GameOver(ContentManager c, Rectangle b, World w, Powerup power) : base(c, b) { //Initialize Everything items = new List<MenuItem>(); world = w; pUp = power; MenuTex = c.Load<Texture2D>("gameover"); restart = new Button(new Vector2(300.0f, 200.0f), c.Load<Texture2D>("restart")); quit = new Button(new Vector2(300.0f, 300.0f), c.Load<Texture2D>("quit")); score = new Label(new Vector2(100.0f, 100.0f), c.Load<Texture2D>("quit"), "Your Score: " + w.score/10 + " meters"); try { StreamReader reader = new StreamReader("highScore.txt"); high = Double.Parse(reader.ReadLine()); reader.Close(); if (high < w.score) { high = w.score; StreamWriter writer = new StreamWriter("highScore.txt", false); writer.Write(Math.Round(high, 2)); writer.Close(); } } catch (Exception e) { high = w.score; StreamWriter writer = new StreamWriter("highScore.txt", false); writer.Write(Math.Round(high, 2)); writer.Close(); } highScore = new Label(new Vector2(100.0f, 150.0f), c.Load<Texture2D>("quit"), "High Score: " + Math.Round(high, 2) / 10 + " meters"); buttonClick = c.Load<SoundEffect>("Audio/WAVs/Buttons/button2"); //Add everything to the array of items. isActive = true; items.Add(restart); items.Add(quit); items.Add(score); items.Add(highScore); //Finish some initialization content = c; }
/// <summary> /// Constructor /// </summary> /// <param name="c">Content Manager</param> /// <param name="p">The Player</param> /// <param name="b">Bounding Rectangle - Displays the menu of set size</param> /// <param name="w">The World that the Game takes place in</param> public PauseMenu(ContentManager c, Rectangle b, World w, Powerup power) : base(c, b) { //Initialize Everything items = new List<MenuItem>(); world = w; pUp = power; resume = new Button(new Vector2(300.0f, 150.0f), c.Load<Texture2D>("continue")); restart = new Button(new Vector2(300.0f, 250.0f), c.Load<Texture2D>("restart")); quit = new Button(new Vector2(300.0f, 350.0f), c.Load<Texture2D>("quit")); buttonClick = c.Load<SoundEffect>("Audio/WAVs/Buttons/button2"); //Add everything to the array of items. isActive = true; items.Add(resume); items.Add(restart); items.Add(quit); //Finish some initialization content = c; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here world = new World(graphics); base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here world = new World(graphics, this); sizeFactor = world.sizeFactor; backgrounds = new List<Texture2D>(); playerAnimation = new List<Texture2D>(); rocks = new List<Texture2D>(); //bgs = new Texture2D[3]; //rects = new Rectangle[bgs.Length]; base.Initialize(); }