コード例 #1
0
ファイル: HeadUpDisplay.cs プロジェクト: 67-6f-64/HelloWorld
        private void GenerateHealthBuffer()
        {
            if (lastHealth == player.Health)
            {
                return;
            }
            VertexBuffer.Dispose(ref healthBuffer);
            float pixel = 1f / 256f;
            float texX  = 16f * pixel;
            float texY  = 0;

            t.StartDrawingAlphaTexturedQuads("icons");
            Vector4 color = new Vector4(1, 1, 1, 1);
            float   posx  = 0;

            for (int i = 0; i < 10; i++)
            {
                t.SetTextureQuad(new Vector2(texX, texY), 9f * pixel, 9f * pixel);
                t.AddVertexWithColor(new Vector4(posx + 0f, 0f, 0f, 1.0f), color);
                t.AddVertexWithColor(new Vector4(posx + 0f, 9f, 0f, 1.0f), color);
                t.AddVertexWithColor(new Vector4(posx + 9f, 9f, 0f, 1.0f), color);
                t.AddVertexWithColor(new Vector4(posx + 9f, 0f, 0f, 1.0f), color);
                if (i < (int)(player.Health / 10f))
                {
                    t.SetTextureQuad(new Vector2(texX + pixel * 4f * 9f, texY), 9f * pixel, 9f * pixel);
                    t.AddVertexWithColor(new Vector4(posx + 0f, 0f, 0f, 1.0f), color);
                    t.AddVertexWithColor(new Vector4(posx + 0f, 9f, 0f, 1.0f), color);
                    t.AddVertexWithColor(new Vector4(posx + 9f, 9f, 0f, 1.0f), color);
                    t.AddVertexWithColor(new Vector4(posx + 9f, 0f, 0f, 1.0f), color);
                }
                posx += 9f;
            }
            healthBuffer = t.GetVertexBuffer();
            lastHealth   = player.Health;
        }
コード例 #2
0
        private void RenderChar(Vector4 color, char character, float posx, float posy)
        {
            if (character == ' ')
            {
                return;
            }
            int   index = fontMap.IndexOf(character);
            float texX  = (int)(index % 16);
            float texY  = (int)(index / 16);

            t.SetTextureQuad(new Vector2(texX / 16f, texY / 16f), 1f / 16f, 1f / 16f);
            t.AddVertexWithColor(new Vector4(posx + 0f, posy + 0f, 0f, 1.0f), color);
            t.AddVertexWithColor(new Vector4(posx + 0f, posy + LineHeight, 0f, 1.0f), color);
            t.AddVertexWithColor(new Vector4(posx + CharWidth, posy + LineHeight, 0f, 1.0f), color);
            t.AddVertexWithColor(new Vector4(posx + CharWidth, posy + 0f, 0f, 1.0f), color);
        }