当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsDevice.DrawRect方法代码示例

本文整理汇总了C#中MiswGame2007.GraphicsDevice.DrawRect方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.DrawRect方法的具体用法?C# GraphicsDevice.DrawRect怎么用?C# GraphicsDevice.DrawRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MiswGame2007.GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.DrawRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

 public override void Draw(GraphicsDevice graphics)
 {
     int drawX = (int)Math.Round(position.X) - game.IntCameraX;
     int drawY = (int)Math.Round(position.Y) - game.IntCameraY;
     if (animation < 32)
     {
         graphics.DrawRect(drawX - 2, drawY - 512, 4, 512, animation % 2 == 0 ? 255 : 0, 255, 255, 4 * animation);
         graphics.DrawRect(drawX - 1, drawY - 512, 2, 512, animation % 2 == 0 ? 255 : 0, 255, 255, 8 * animation);
     }
     else
     {
         graphics.DrawImageAdd(GameImage.OyajiThunder, 32, 512, 0, animation / 2 % 8, drawX - 16, drawY - 512, 255 - 16 * (animation - 32), animation % 2 == 0 ? 255 : 0, 255, 255);
     }
 }
开发者ID:sinshu,项目名称:chaos,代码行数:14,代码来源:OyajiThunder.cs

示例2: DrawPlayerInfo

        public void DrawPlayerInfo(GraphicsDevice graphics, int alpha)
        {
            graphics.DrawImageAlpha(GameImage.Hud, 32, 32, 2, 0, 8, Settings.SCREEN_HEIGHT - 40, alpha);
            for (int i = 0; i < 6; i++)
            {
                graphics.DrawImageAlpha(GameImage.Hud, 32, 32, 2, 1, 8 + 32 + 32 * i, Settings.SCREEN_HEIGHT - 40, alpha);
            }
            graphics.DrawImageAlpha(GameImage.Hud, 32, 32, 2, 2, 8 + 32 + 192, Settings.SCREEN_HEIGHT - 40, alpha);
            if (player.DrawHealth > 0)
            {
                int damageCount = player.DamageCount;
                graphics.DrawRect(8 + 32, Settings.SCREEN_HEIGHT - 40 + 10, 2 * player.DrawHealth, 1, 255, 128 + damageCount / 2, 128 + damageCount / 2, alpha);
                graphics.DrawRect(8 + 32, Settings.SCREEN_HEIGHT - 40 + 10 + 1, 2 * player.DrawHealth, 12 - 2, 255, damageCount, damageCount, alpha);
                graphics.DrawRect(8 + 32, Settings.SCREEN_HEIGHT - 40 + 10 + 11, 2 * player.DrawHealth, 1, 128 + damageCount / 2, damageCount, damageCount, alpha);
            }

            if (player.CurrentWeapon != Player.Weapon.Pistol)
            {
                graphics.DrawImageAlpha(GameImage.Hud, 96, 32, 3, 0, 8, Settings.SCREEN_HEIGHT - 80, alpha);

                switch (player.CurrentWeapon)
                {
                    case Player.Weapon.Machinegun:
                        graphics.DrawImageAlpha(GameImage.Item, 32, 32, 0, 0, 9, Settings.SCREEN_HEIGHT - 80, alpha);
                        break;
                    case Player.Weapon.Rocket:
                        graphics.DrawImageAlpha(GameImage.Item, 32, 32, 2, 0, 9, Settings.SCREEN_HEIGHT - 80, alpha);
                        break;
                    case Player.Weapon.Shotgun:
                        graphics.DrawImageAlpha(GameImage.Item, 32, 32, 1, 0, 9, Settings.SCREEN_HEIGHT - 80, alpha);
                        break;
                    case Player.Weapon.Flamethrower:
                        graphics.DrawImageAlpha(GameImage.Item, 32, 32, 3, 0, 9, Settings.SCREEN_HEIGHT - 80, alpha);
                        break;
                }
            }
            int ammo = player.Ammo;
            if (ammo / 100 > 0)
            {
                DrawNumber(graphics, ammo / 100 % 10, 40, Settings.SCREEN_HEIGHT - 80, alpha, player.AmmoNumColorCount);
            }
            if (ammo / 10 > 0)
            {
                DrawNumber(graphics, ammo / 10 % 10, 40 + 19, Settings.SCREEN_HEIGHT - 80, alpha, player.AmmoNumColorCount);
            }
            if (ammo > 0)
            {
                DrawNumber(graphics, ammo % 10, 40 + 19 + 19, Settings.SCREEN_HEIGHT - 80, alpha, player.AmmoNumColorCount);
            }

            if (player.AmmoHudColorCount > 0)
            {
                graphics.DrawImageAlpha(GameImage.Hud, 96, 32, 3, 1, 8, Settings.SCREEN_HEIGHT - 80, player.AmmoHudColorCount * alpha / 255);
            }
        }
开发者ID:sinshu,项目名称:chaos,代码行数:55,代码来源:GameScene.cs


注:本文中的MiswGame2007.GraphicsDevice.DrawRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。