當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。