Example #1
0
        public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1)
        {
            if (!editing || !MapEntity.SelectedList.Contains(item))
            {
                return;
            }

            Vector2 pos = new Vector2(item.DrawPosition.X, -item.DrawPosition.Y);

            ShapeExtensions.DrawLine(spriteBatch, pos + Vector2.UnitY * range, pos - Vector2.UnitY * range, Color.Cyan * 0.5f, 2);
            ShapeExtensions.DrawLine(spriteBatch, pos + Vector2.UnitX * range, pos - Vector2.UnitX * range, Color.Cyan * 0.5f, 2);
            ShapeExtensions.DrawCircle(spriteBatch, pos, range, 32, Color.Cyan * 0.5f, 3);
        }
Example #2
0
        private void GameDraw()
        {
            GraphicsDevice.Clear(new Color(46, 204, 113));
            GraphicsDevice.BlendState = BlendState.NonPremultiplied;

            mapRenderer.Draw(seaMap, cam.GetViewMatrix());

            // world space here
            spriteBatch.Begin(transformMatrix: cam.GetViewMatrix(), samplerState: SamplerState.PointClamp);

            player.playerOffset = new Vector2(playerSprite.Width / 2, playerSprite.Height / 2);
            //spriteBatch.Draw(splashScreen, new Vector2(0, 0), Color.Silver);

            foreach (Projectile can in player.projectiles)
            {
                spriteBatch.Draw(cannonballSprite, can.CannonPosition, null, Color.White, 0, Vector2.Zero, 0.5f, SpriteEffects.None, 0);
            }
            //spriteBatch.Draw(playerSprite, player.Position, Color.White);
            spriteBatch.Draw(playerSprite, player.PlayerPosition, null, Color.White, player.playerRotation, player.playerOffset, 1, SpriteEffects.None, 0);

            foreach (Enemy e in enemies)
            {
                spriteBatch.Draw(e.texture, e.Position, null, Color.White, e.enemyRotation, new Vector2(e.texture.Width / 2, e.texture.Height / 2), 1, SpriteEffects.None, 1);
                ShapeExtensions.DrawLine(spriteBatch, e.Position + new Vector2(18, -e.texture.Height / 1.5f), 44, 0, Color.Black, 6);
                ShapeExtensions.DrawLine(spriteBatch, e.Position + new Vector2(20, -e.texture.Height / 1.5f), e.health * 40 / e.maxHealth, 0, Color.Green, 4);
            }


            spriteBatch.End();
            spriteBatch.Begin();

            spriteBatch.DrawString(gameText, "Score: " + score, new Vector2(30, 30), Color.Black, 0, new Vector2(0, 0), 1 * 1.5f, SpriteEffects.None, 0);
            for (int i = 0; i < player.PlayerHealth; i++)
            {
                spriteBatch.Draw(health, new Vector2(ScreenX - (health.Width + 30) - (i * 64), 30), Color.White);
            }
            spriteBatch.End();
        }