コード例 #1
0
ファイル: Ball.cs プロジェクト: bkgood/misc-code
 public Ball(Game game)
     : base(game)
 {
     UpdateOrder = BrickInvaders.BallPriority;
     paddle = (Paddle) game.Services.GetService(typeof(Paddle));
     tileMatrix = (TileMatrix) game.Services.GetService(typeof(TileMatrix));
 }
コード例 #2
0
ファイル: BrickInvaders.cs プロジェクト: bkgood/misc-code
        /// <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();
        }