Пример #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(0, 0, 20));

            // TODO: Add your drawing code here
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, Camera.Transform);
            RenderWorld(spriteBatch);
            AsteroidsField.Render(spriteBatch);
            spriteBatch.End();
        }
Пример #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            AsteroidsField.Update(gameTime);

            base.Update(gameTime);
        }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            cacheTextures();
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            player = new Player(new Vector2(1000, 1000), new Dimension(64, 64));
            Entities.Add(player);

            AsteroidsField = new AsteroidsField(new Rectangle(0, 0, 4000, 4000));
            AsteroidsField.LoadContent(Content);

            Camera = new EntityCenteredCamera(GetResolution(), player);

            // TODO: use this.Content to load your game content here
            base.LoadContent();
        }