Example #1
0
 public Game(Window window)
 {
     highScores = new int[10];
     TryLoadingHighscores();
     SetUpBackground();
     mainMenu = new Menu();
     mainMenu.InitGame += StartGame;
     mainMenu.QuitGame += window.CloseAfterFrame;
     InteractionLogic = new InteractionLogic();
     mainMenu.UpdateHighscoreDisplay(highScores);
 }
Example #2
0
        protected override void LoadContent()
        {
            // initialize sprite batching and the sprite sheet collection
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteSheets = SpriteSheetCollection.parseFrom(settings.spriteSheetFileName, content);
            if(spriteSheets == null) { Exit(); }

            // initialize the game management systems
            projectileSystem = new ProjectileSystem(spriteSheets, settings, content);
            spaceShipSystem = new SpaceShipSystem(spriteSheets, projectileSystem, settings, content);
            asteroidSystem = new AsteroidSystem(spriteSheets, spaceShipSystem, settings);
            explosionSystem = new ExplosionSystem(spriteSheets, content);
            scoreSystem = new ScoreSystem(spaceShipSystem, content, settings);
            collisionSystem = new CollisionSystem(projectileSystem, spaceShipSystem, asteroidSystem, explosionSystem, scoreSystem);

            // initialize the menu
            menu = new Menu(this, spaceShipSystem, settings, content);

            // load and start the background music (if appropriate)
            backgroundMusic = content.Load<Song>("myg0t");
            MediaPlayer.IsRepeating = true;
            if(settings.musicEnabled) {
                MediaPlayer.Play(backgroundMusic);
            }
        }