예제 #1
0
파일: Paddle.cs 프로젝트: bkgood/misc-code
        /// <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()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            texture = Game.Content.Load<Texture2D>(@"Images\Paddle");
            controls = (Controls) Game.Services.GetService(typeof(Controls));
            location.X = Game.Window.ClientBounds.Width / 2 - texture.Width / 2;
            location.Y = Game.Window.ClientBounds.Height - texture.Height * 3;

            base.Initialize();
        }
예제 #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()
        {
            graphics.PreferredBackBufferWidth = 800;
            graphics.PreferredBackBufferHeight = 600;
            graphics.ApplyChanges();
            Window.Title = "Brick Invaders – CS 4173, Assignment 6 – Bill Good";

            if (GamePad.GetCapabilities(PlayerIndex.One).IsConnected) {
                Components.Add(controls = new GamePadControls(this, PlayerIndex.One));
            } else {
                Components.Add(controls = new KeyboardControls(this));
            }
            Services.AddService(typeof(Controls), controls);

            Components.Add(tileMatrix = new TileMatrix(this, tileTextures));
            Services.AddService(typeof(TileMatrix), tileMatrix);

            Components.Add(paddle = new Paddle(this));
            Services.AddService(typeof(Paddle), paddle);
            Components.Add(ball = new Ball(this));
            Services.AddService(typeof(Ball), ball);
            base.Initialize();
        }