Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void DrawString(string s, Vector2 startPos, SpriteBatch spriteBatch, int maxWidth = 300)
- {
- Vector2 currentPosition = startPos;
- char[] chars = s.ToCharArray();
- int length = 0;
- int currentLine = 1;
- float ylock = startPos.Y;
- for(int i = 0; i < s.Length; i++)
- {
- if(chars[i] == wavyChar)
- {
- waving = !waving;
- }
- else if(chars[i] == jitterChar)
- {
- jittering = !jittering;
- }
- else if(chars[i] == phaseChar)
- {
- phasing = !phasing;
- }
- else if(chars[i] == screamChar)
- {
- screaming = !screaming;
- }
- else
- {
- int incr;
- if (i != 0)
- incr = MeasureChar(chars[i - 1]);
- else
- incr = 0;
- if (waving)
- {
- //no lerp/rough
- //currentPosition += new Vector2(incr, (float)Math.Floor(Math.Cos((animationIncrement / 7) + (i / 2)) * 2.2));
- //lerp/smooth
- currentPosition += new Vector2(incr, (float)(Math.Cos((animationIncrement / 7) + (i / 2)) * 2.2));
- }
- else if (jittering)
- {
- currentPosition += new Vector2(incr, (float)Math.Cos((animationIncrement + (i * 1.2f)) * .9f));
- }
- else if (phasing)
- {
- currentPosition += new Vector2(incr, (float)Math.Cos((animationIncrement) * 3));
- }
- else if (screaming)
- {
- currentPosition += new Vector2(incr + (float)Math.Cos((animationIncrement) * 2f), (float)Math.Cos((animationIncrement + (i / 2))));
- }
- else
- {
- currentPosition += new Vector2(incr, 0);
- }
- length += incr;
- Vector2 dictPos = charPosition[chars[i]];
- Rectangle charSource = new Rectangle((int)dictPos.X, (int)dictPos.Y, charPositionSize, charPositionSize);
- if (chars[i] == ' ' && i != s.Length - 1)
- {
- if (length + LengthOfNextWord(s.Substring(i)) > maxWidth)
- {
- currentLine++;
- currentPosition = startPos + new Vector2(-MeasureChar(' '), (currentLine * charPositionSize) + verticalSpacing);
- ylock = currentPosition.Y;
- length = 0;
- }
- }
- spriteBatch.Draw
- (
- texture: mainFont,
- sourceRectangle: charSource,
- position: currentPosition,
- color: Color.White
- );
- }
- currentPosition = new Vector2(currentPosition.X, ylock);
- }
- waving = false;
- jittering = false;
- phasing = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement