Beispiel #1
0
 /// <summary>
 /// Default Constructor for the Engine object
 /// </summary>
 /// <param name="g"> The Game object the Engine runs </param>
 /// <param name="eventM"> The EventManager object associated with the Engine </param>
 /// <param name="menuM"> The MenuManager object associated with the Engine </param>
 public Engine(Game g, EventManager eventM, MenuManager menuM)
     : base(g)
 {
     graphics = (GraphicsDeviceManager)g.Services.GetService(typeof (IGraphicsDeviceManager));
     IGraphicsDeviceService graphicsDeviceService = (IGraphicsDeviceService)g.Services.GetService(typeof(IGraphicsDeviceService));
     spriteBatch = new SpriteBatch(graphicsDeviceService.GraphicsDevice);
     this.EventM = eventM;
     this.MenuM = menuM;
     spriteList = new List<Sprite>();
     staticSpriteList = new List<StaticSprite>();
 }
Beispiel #2
0
        /// <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()
        {
            // Initializes engine subsystems

            // Initializes the inputManager object
            inputM = new InputManager(this);
            // Initializes the eventManager object. Sets updates to 100/second and keeps draws at 60/second.
            eventM = new EventManager(this, 100, true);
            // Initializes the loadManager object
            loadM = new LoadManager(this);
            // Initializes the setupManager object
            setupM = new SetupManager();
            // Initializes the textManager object
            textM = new TextManager(this);
            // Initializes the menuManager object
            menuM = new MenuManager(this, textM);
            // Initializes the fileManager object
            fileM = new FileManager("Asteroids 2");
            // Initializes the engine object
            engine = new Engine(this, eventM, menuM);

            Components.Add(inputM);
            Components.Add(eventM);
            Components.Add(loadM);
            Components.Add(textM);
            Components.Add(menuM);
            Components.Add(engine);

            //// Set screen size
            engine.SetScreen(screenSize.Width, screenSize.Height);

            base.Initialize();
        }