Ejemplo n.º 1
0
        private List <RaceCar> raceCars; // the object will occur collision

        /// <summary>
        /// main constructor of this class
        /// </summary>
        /// <param name="game">Provides basic graphics device initialization, game logic, and rendering code</param>
        /// <param name="myCar">the myCar checking the collision</param>
        /// <param name="raceCars">the car checking the collision</param>
        public CollisionManager(Game game,
                                MyCar myCar,
                                List <RaceCar> raceCars) : base(game)
        {
            // Initialize all member variables
            this.game     = game;
            this.myCar    = myCar;
            this.raceCars = raceCars;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            Game1.nLevel = 1;

            road = new Road(game, spriteBatch, game.Content.Load <Texture2D>("images/road"));
            this.Components.Add(road);

            myCar = new MyCar(game, spriteBatch, game.Content.Load <Texture2D>("images/myCar"));
            this.Components.Add(myCar);

            explode = new Explode(game, spriteBatch, game.Content.Load <Texture2D>("images/explode"));
            this.Components.Add(explode);

            raceCarLists = new List <RaceCar>();

            colManager = new CollisionManager(game, myCar, raceCarLists);
            this.Components.Add(colManager);

            hudMessage = new HudMessage(game, spriteBatch);
            this.Components.Add(hudMessage);

            base.Initialize();
        }