/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteWalk.LoadSprite(Content.Load <Texture2D>("StickAnimation"), (int)PlayerVector.X, (int)PlayerVector.Y, 0, 0, 6, 50, 100, 15); spriteWin.LoadSprite(Content.Load <Texture2D>("StickAnimation"), (int)PlayerVector.X, (int)PlayerVector.Y, 0, 100, 6, 50, 100, 15); duckTexture = Content.Load <Texture2D>("StickDuck"); stand = Content.Load <Texture2D>("Stick"); jumpUp = Content.Load <Texture2D>("StickJumpUp"); jumpDown = Content.Load <Texture2D>("StickJumpDown"); Texture2D projectile = Content.Load <Texture2D>("projectile"); Texture2D badGuys = Content.Load <Texture2D>("badStickAnimation"); brick = Content.Load <Texture2D>("brick"); blankLevel = Content.Load <Texture2D>("blankLevel"); lvl = new Level(brick, badGuys, projectile, blankLevel, GraphicsDevice, spriteBatch); // TODO: use this.Content to load your game content here }
public Vector2 loadCurrentLevel(string FileName) { currLvlText.SetData <Color>(blankLevel); Vector2 PlayerVector = new Vector2(); projectileArr = new Projectile[50];//arbitrary value isDoorOpen = false; levelFile = File.ReadAllLines(FileName); collisionCheck = new int[levelFile[0].Length, levelFile.Length]; destroyTheseBricks = new bool[levelFile[0].Length, levelFile.Length]; destructBrickArr = new AnimatedSprite[levelFile[0].Length, levelFile.Length]; badShooters = new AnimatedSprite[levelFile[0].Length, levelFile.Length]; int x, y, lineY, valueX, currProjectile;// 20 by 20 x = 0; y = 0; lineY = 0; valueX = 0; currProjectile = 0; foreach (string line in levelFile) { foreach (char value in line) { if (value == '-') { collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), contBrick, 0, contBrick.Length); } if (value == '[') { collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), beginBrick, 0, contBrick.Length); } if (value == ']') { collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), endBrick, 0, contBrick.Length); } if (value == '_') { collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), singleBrick, 0, contBrick.Length); } if (value == 'T') { doorX = x; doorY = y; collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), topDoor, 0, contBrick.Length); } if (value == '|') { collisionCheck[valueX, lineY] = 1; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), botDoor, 0, contBrick.Length); openDoor.LoadSprite(brick, x + (brickSize / 2), y, 0, 0, 6, brickSize, brickSize * 2, 10); } if (value == 'X') { collisionCheck[valueX, lineY] = 2; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), destructBrick, 0, contBrick.Length); destructBrickArr[valueX, lineY] = new AnimatedSprite(); destructBrickArr[valueX, lineY].LoadSprite(brick, x + (brickSize / 2), y + (brickSize / 2), 0, 6 * brickSize, 3, brickSize, brickSize, 15); } if (value == '>')//shooter facing right { collisionCheck[valueX, lineY] = 4; collisionCheck[valueX, lineY - 1] = 4; badShooters[valueX, lineY] = new AnimatedSprite(); badShooters[valueX, lineY].LoadSprite(badGuys, x + brickSize / 2, y, 0, 0, 7, 50, 100, 9, true); projectileArr[currProjectile] = new Projectile(x, y, true, projectile); currProjectile++; } if (value == '<') { collisionCheck[valueX, lineY] = 4; collisionCheck[valueX, lineY - 1] = 4; badShooters[valueX, lineY] = new AnimatedSprite(); badShooters[valueX, lineY].LoadSprite(badGuys, x + brickSize / 2, y, 0, 0, 7, 50, 100, 9, false); projectileArr[currProjectile] = new Projectile(x, y, false, projectile); currProjectile++; } if (value == 'C') { collisionCheck[valueX, lineY] = 3; totalCollectables++; currLvlText.SetData <Color>(0, new Rectangle(x, y, brickSize, brickSize), collectable, 0, contBrick.Length); } if (value == 'O') { PlayerVector.X = (float)x; PlayerVector.Y = (float)y; } x += brickSize; valueX++; } x = 0; y += brickSize; valueX = 0; lineY++; } return(PlayerVector); }