Exemplo n.º 1
0
        // Draw shaky gahame text
        public static void DrawShakingText(SpriteBatch spriteBatch, GameFont font, string text, Vector2 pos, float intensity, Color c)
        {
            // the offset for each char
            Vector2 offset = new Vector2(0, 0);

            text = Gahamefy(text);

            // draw each char
            for (int i = 0; i < text.Length; i++)
            {
                Vector2 shake = new Vector2(MyMaths.RandomInRange(-intensity, intensity), MyMaths.RandomInRange(-intensity, intensity));

                string textToDraw;
                if (IsCons(text[i]))
                {
                    if (i != text.Length - 1)
                    {
                        if (IsVowel(text[i + 1]))
                        {
                            textToDraw = "" + text[i] + text[i + 1];
                            i++;
                        }
                        else
                        {
                            textToDraw = "" + text[i];
                        }
                    }
                    else
                    {
                        textToDraw = "" + text[i];
                    }
                }
                else
                {
                    textToDraw = "" + text[i];
                }

                font.DrawString(spriteBatch, textToDraw, pos + offset + shake, c);

                offset.X += font.MeasureString(textToDraw).X;

                if (text[i] == '\n')
                {
                    offset.X  = 0;
                    offset.Y += font.LineSpacing;
                }
            }
        }
Exemplo n.º 2
0
        // Draw shaky text
        public static void DrawShakingText(SpriteBatch spriteBatch, SpriteFont font, string text, Vector2 pos, float intensity, Color c)
        {
            // the offset for each char
            Vector2 offset = new Vector2(0, 0);

            // draw each char
            for (int i = 0; i < text.Length; i++)
            {
                Vector2 shake = new Vector2(MyMaths.RandomInRange(-intensity, intensity), MyMaths.RandomInRange(-intensity, intensity));
                spriteBatch.DrawString(font, "" + text[i], pos + offset + shake, c);

                offset.X += font.MeasureString("" + text[i]).X;

                if (text[i] == '\n')
                {
                    offset.X  = 0;
                    offset.Y += font.LineSpacing;
                }
            }
        }