Exemple #1
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()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            player = new Player(this);
            var commands = new IConsoleCommand[] { new MovePlayerCommand(player), new RotatePlayerDegreesCommand(player) };
            console = new GameConsole(this, spriteBatch, commands, new GameConsoleOptions
                                                                       {
                                                                           Font = Content.Load<SpriteFont>("GameFont"),
                                                                           FontColor = Color.LawnGreen,
                                                                           Prompt = "~>",
                                                                           PromptColor = Color.Crimson,
                                                                           CursorColor = Color.OrangeRed,
                                                                           BackgroundColor = new Color(Color.Black,150),
                                                                           PastCommandOutputColor = Color.Aqua,
                                                                           BufferColor = Color.Gold
                                                                       });
            console.AddCommand("rotRad", a =>
                                             {
                                                 var angle = float.Parse(a[0]);
                                                 player.Angle = angle;
                                                 return String.Format("Rotated the player to {0} radians", angle);
                                             });
            base.Initialize();
        }
 public MovePlayerCommand(Player player)
 {
     this.player = player;
 }
 public RotatePlayerDegreesCommand(Player player)
 {
     this.player = player;
 }