Пример #1
0
        public virtual void Draw(SpriteBatch spriteBatch, Vector2 mapOffset, float blockSize)
        {
            var texture = GameContent.GetTexture(TextureName);
            var scale   = blockSize / texture.Height * 2f;

            spriteBatch.Draw(texture, mapOffset + Position * blockSize, null, Color.White,
                             Convert.ToSingle(rotation), new Vector2(texture.Width, texture.Height) * 0.5f,
                             scale, SpriteEffects.None, 0.0f);
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent( )
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Fonts.Load(Content);
            GameContent.Load(Content);
            ScreenStack.Push(new MainMenu( ));
            var song = Content.Load <Song>("biisit/tuuli");

            MediaPlayer.Play(song);
        }
Пример #3
0
 public GameScreen( )
 {
     for (int x = 0; x < AREA_SIZE; x++)
     {
         for (int y = 0; y < AREA_SIZE; y++)
         {
             _terrain[x, y] = new TerrainPiece((x + y) % 2 == 0 ? "grass" : "sand");
         }
     }
     _player = new PlayerCharacter {
         Position = Vector2.One * AREA_SIZE * 0.5f
     };
     MediaPlayer.Play(GameContent.GetSong("biisit/niitty"));
 }
Пример #4
0
 public override void Draw(ContentManager contentManager, SpriteBatch spriteBatch, Rectangle screenSize)
 {
     base.Draw(contentManager, spriteBatch, screenSize);
     for (int x = 0; x < AREA_SIZE; x++)
     {
         for (int y = 0; y < AREA_SIZE; y++)
         {
             double blockSize   = screenSize.Height / Convert.ToDouble(AREA_SIZE);
             var    destination = new Rectangle(
                 Convert.ToInt32(MapOffset.X + x * blockSize),
                 Convert.ToInt32(y * blockSize),
                 Convert.ToInt32(blockSize + 1),
                 Convert.ToInt32(blockSize + 1));
             _terrain[x, y].Draw(spriteBatch, destination);
         }
     }
     _player.Draw(spriteBatch, MapOffset, BlockSize);
     foreach (var bullet in _bullets)
     {
         bullet.Draw(spriteBatch);
     }
     spriteBatch.Draw(GameContent.GetTexture("target"), new Vector2(mouseState.X, mouseState.Y), null,
                      Color.White, 0f, Vector2.One * 100f, 1.5f * BlockSize / 100f, SpriteEffects.None, 0f);
 }
Пример #5
0
 public void Draw(SpriteBatch spriteBatch, Rectangle destination)
 {
     spriteBatch.Draw(GameContent.GetTexture("block_" + _terrainName), destination, Color.White);
 }
Пример #6
0
        } // update

        private void Hit(HitState state)
        {
            _hitState = state;
            _hitTime  = DateTime.Now;
            GameContent.GetSound("hit").Play( );
        }
Пример #7
0
 public void Draw(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(GameContent.GetTexture("bullet"), Position, null, Color.White, 0.0f,
                      new Vector2(16.0f, 16.0f), 0.3f, SpriteEffects.None, 0.0f);
 }