private void InializeGameValues() { sparrow = new Sparrow(Content); obstacles = new List<Obstacle>(); firstObstacle = true; level = 1; newHighScore = false; if (GameUtils.cityLevel) { background = Content.Load<Texture2D>("citybackground"); scrollingBackground = new ScrollingBackground(); scrollingBackground.Load(background); theme = Content.Load<Song>("sounds/citytheme"); } else { background = Content.Load<Texture2D>("castlesbackground"); scrollingBackground = new ScrollingBackground(); scrollingBackground.Load(background); theme = Content.Load<Song>("sounds/castletheme"); } GameUtils.obstacleSpeed = 2f; maxObstaclesTime = 2000; gameScore = 0; obstcaleTimeElapsed = 0; scrollingBackground.Reset(); gameOver = false; gamePaused = false; }
/// <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); if (GameUtils.cityLevel) { theme = Content.Load<Song>("sounds/citytheme"); } else { theme = Content.Load<Song>("sounds/castletheme"); } intro = Content.Load<Song>("sounds/gameintro"); pauseSound = Content.Load<SoundEffect>("sounds/gamepause"); gameoverSound = Content.Load<SoundEffect>("sounds/gameover"); GameUtils.fontScore = Content.Load<SpriteFont>("sfont"); GameUtils.fontLevel = Content.Load<SpriteFont>("sfont"); fontHighScore = Content.Load<SpriteFont>("bigfont"); fontNewScore = Content.Load<SpriteFont>("mediumfont"); if (GameUtils.cityLevel) { background = Content.Load<Texture2D>("citybackground"); scrollingBackground = new ScrollingBackground(); scrollingBackground.Load(background); } else { background = Content.Load<Texture2D>("castlesbackground"); scrollingBackground = new ScrollingBackground(); scrollingBackground.Load(background); } tapToFly = Content.Load<Texture2D>("taptofly"); avatar = Content.Load<Texture2D>("sparrow_avatar"); flappysparrow = Content.Load<Texture2D>("flappysparrow"); gameovertext = Content.Load<Texture2D>("gameover"); highscoredialog = Content.Load<Texture2D>("highscoredialog"); gamescoredialog = Content.Load<Texture2D>("gamescoredialog"); btPause = Content.Load<Texture2D>("pauseblue"); btPauseGray = Content.Load<Texture2D>("pausegray"); btMenu = Content.Load<Texture2D>("exitmenu"); btScore = Content.Load<Texture2D>("highscore"); btStart = Content.Load<Texture2D>("menustart"); btRestart = Content.Load<Texture2D>("menurestart"); btMute = Content.Load<Texture2D>("mutesound"); btUnmute = Content.Load<Texture2D>("unmutesound"); btMenuLevelCastles = Content.Load<Texture2D>("menucastles"); btMenuLevelCity = Content.Load<Texture2D>("menucity"); int btPauseH = (int)btPause.Height; int btPauseW = (int)btPause.Width; int btMenuH = (int)btStart.Height; int btMenuW = (int)btStart.Width; int btMuteH = (int)btMute.Height; int btMuteW = (int)btMute.Width; btPauseRectangle = new Rectangle((int)GameUtils.viewport_dimensions.X - btPause.Width - 70, 10, btPauseW, btPauseH); btRectangleLevel = new Rectangle( (int)GameUtils.viewport_dimensions.X / 2 - btMenuW / 2, (int)GameUtils.viewport_dimensions.Y / 2 - btMenuH / 2 + 65, btMenuW, btMenuH ); btStartRectangle = new Rectangle( (int)GameUtils.viewport_dimensions.X / 2 - btMenuW / 2, (int)GameUtils.viewport_dimensions.Y / 2 - btMenuH / 2 - 35, btMenuW, btMenuH ); btScoreRectangle = new Rectangle( (int)GameUtils.viewport_dimensions.X / 2 - btMenuW / 2, (int)GameUtils.viewport_dimensions.Y / 2 - btMenuH / 2 + 15, btMenuW, btMenuH ); btRestartRectangle = new Rectangle( (int)GameUtils.viewport_dimensions.X / 2 - btMenuW / 2, (int)GameUtils.viewport_dimensions.Y / 2 - btMenuH / 2 + 5, btMenuW, btMenuH ); btMenuRectangle = new Rectangle( (int)GameUtils.viewport_dimensions.X / 2 - btMenuW / 2, (int)GameUtils.viewport_dimensions.Y / 2 - btMenuH / 2 + 55, btMenuW, btMenuH ); btRectangleMute = new Rectangle( (int)GameUtils.viewport_dimensions.X - btMute.Width - 10, 10,//(int)GameUtils.viewport_dimensions.Y - btMute.Height - 10, btMuteW, btMuteH ); if (MediaPlayer.GameHasControl) { MediaPlayer.Volume = MediaPlayer.Volume - 0.6f; if (MediaPlayer.State == MediaState.Playing) MediaPlayer.Stop(); if (!GameUtils.muteEnabled) MediaPlayer.Play(intro); } InializeGameValues(); base.LoadContent(); }