private void SecondFrameLevelObject(int windowHeight) { List<GameObject> childLevelObjects = new List<GameObject>(); Texture2D backgroundTexture = this.gameContent.Load<Texture2D>("Backgrounds/Background"); Vector2 backgroundPosition = new Vector2(xPosition, windowHeight - backgroundTexture.Height); GameObject backgroundObject = new GameObject(backgroundTexture, backgroundPosition); backgroundObjects.Add(backgroundObject); Texture2D floorTexture = this.gameContent.Load<Texture2D>("Backgrounds/Floor"); Vector2 floorPosition = new Vector2(xPosition, windowHeight - floorTexture.Height); GameObject floorObject = new GameObject(floorTexture, floorPosition); childLevelObjects.Add(floorObject); Texture2D stepperTexture = this.gameContent.Load<Texture2D>("Others/Stepper"); Vector2 stepperPosition = new Vector2(xPosition + 350.0f, windowHeight - floorTexture.Height - 200); GameObject stepperObject = new GameObject(stepperTexture, stepperPosition); childLevelObjects.Add(stepperObject); stepperTexture = this.gameContent.Load<Texture2D>("Others/Stepper"); stepperPosition = new Vector2(xPosition + 500.0f, windowHeight - floorTexture.Height - 400); stepperObject = new GameObject(stepperTexture, stepperPosition); childLevelObjects.Add(stepperObject); this.parentLevelObjects.Add(childLevelObjects); xPosition += backgroundTexture.Width; }
/// <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); this.windowWidth = this.graphics.GraphicsDevice.Viewport.Width; this.windowHeight = this.graphics.GraphicsDevice.Viewport.Height; this.windowCenter = this.windowWidth / 2; // Load first level this.initializeFirstLevel = new InitializeFirstLevel(this.Content, this.graphics); this.levelObjectsPerFrame = this.initializeFirstLevel.ObjectsPerFrame; List<GameObject> firstFrameObjects = this.levelObjectsPerFrame[0]; this.floor = firstFrameObjects[0]; // Load player Texture2D playerTexture = Content.Load<Texture2D>("Player/PlayerTurnedRight"); Vector2 playerPosition = new Vector2( this.windowCenter - (playerTexture.Width / 2), (this.floor.BoundingBox.Top - playerTexture.Height) + 1); this.player = new Player(playerTexture, playerPosition); this.playerAbilities = new PlayerAbilities(this.player); this.playerAbilities.JumpingVelocity = JUMPING_VELOCITY; this.playerAbilities.BulletVelocity = BULLET_VELOCITY; // Jumping this.jumpingVelocity = JUMPING_VELOCITY; //// Bullet //Texture2D bulletTexture = Content.Load<Texture2D>("Bullets/bullet_right"); //Vector2 bulletPosition = new Vector2( // this.player.XPosition + this.player.Width, // this.player.YPosition + MUZZLE_OF_GUN_POSITION); //this.bullet = new Bullet(bulletTexture, bulletPosition); //// Shooting sound //this.shootingSound = Content.Load<SoundEffect>("Sounds/ShootingSilencer"); ////this.bugShootingSound = Content.Load<SoundEffect>("Sounds/shootingBugSound"); //// Enemy //this.enemyTexture = Content.Load<Texture2D>("Enemys/enemyTurnedLeft"); //this.enemyPosition = new Vector2(this.windowWidth - this.enemyTexture.Width - 100, this.windowHeight - this.enemyTexture.Height - this.floorTexture.Height); //this.enemyObject = new GameObject(this.enemyTexture, this.enemyPosition); //this.enemyTextureData = new Color[this.enemyTexture.Width * this.enemyTexture.Height]; //this.enemyTexture.GetData(this.enemyTextureData); //// Enemy dying sound //this.enemyDyingSound = Content.Load<SoundEffect>("Sounds/EnemyDyingSound"); //// Bug bullet //this.bugBulletTexture = Content.Load<Texture2D>("Bullets/bugBullet"); //this.bugBulletPosition = new Vector2(this.enemyObject.XPosition, this.enemyObject.YPosition + (this.enemyTexture.Height / 2)); //this.bugBulletObject = new GameObject(this.bugBulletTexture, this.bugBulletPosition); //this.bugBulletTextureData = new Color[this.bugBulletTexture.Width * this.bugBulletTexture.Height]; //this.bugBulletTexture.GetData(this.bugBulletTextureData); //// Stepper //this.stepperTexture = Content.Load<Texture2D>("Others/Stepper"); //this.stepperPosition = new Vector2(300.0f, this.windowHeight - this.floorTexture.Height - 200); //this.stepperObject = new GameObject(this.stepperTexture, this.stepperPosition); //this.stepperTextureData = new Color[this.stepperTexture.Width * this.stepperTexture.Height]; //this.stepperTexture.GetData(this.stepperTextureData); }
private void ThirdFrameLevelObjects(int windowHeight) { List<GameObject> childLevelObjects = new List<GameObject>(); Texture2D backgroundTexture = this.gameContent.Load<Texture2D>("Backgrounds/Background"); Vector2 backgroundPosition = new Vector2(xPosition, windowHeight - backgroundTexture.Height); GameObject backgroundObject = new GameObject(backgroundTexture, backgroundPosition); backgroundObjects.Add(backgroundObject); Texture2D floorTexture = this.gameContent.Load<Texture2D>("Backgrounds/Floor"); Vector2 floorPosition = new Vector2(xPosition, windowHeight - floorTexture.Height); GameObject floorObject = new GameObject(floorTexture, floorPosition); childLevelObjects.Add(floorObject); this.parentLevelObjects.Add(childLevelObjects); xPosition += backgroundTexture.Width; }