Skip to content

Commit

Permalink
Small Text Tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
SWCreeperKing committed Nov 9, 2021
1 parent b5187fa commit d70fd33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class Program : GameLoop
{
// game object init
// if you have objects that just need to render and update
// then use RegisterGameObject()
// then use RegisterGameObj()
}

// tip: DO NOT init new objects everytime in Update/Render Loops
Expand Down
11 changes: 8 additions & 3 deletions RayWrapper/Objs/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@ public override Vector2 Position

public override Vector2 Size => rect.Size();

public TextMode mode => TextMode.Normal;
public TextMode mode = TextMode.Normal;
public Actionable<string> text;
public Rectangle rect;
public ColorModule color;
public float fontSize;
public float spacing;

private Vector2 _pos;
private string _cachedText;

public Text(Actionable<string> text, Vector2 pos, ColorModule color = null, float fontSize = 24,
float spacing = 1.5f)
{
(this.text, this._pos, this.color, this.fontSize, this.spacing, _cachedText) =
(this.text, _pos, this.color, this.fontSize, this.spacing, _cachedText) =
(text, pos, color ?? Color.SKYBLUE, fontSize, spacing, text);
rect = RectWrapper.AssembleRectFromVec(pos, MeasureText());
}

public Text(Actionable<string> text, Rectangle rect, ColorModule color = null, float fontSize = 24,
float spacing = 1.5f) =>
(this.rect, this.text, _pos, this.color, this.fontSize, this.spacing, _cachedText) = (rect, text,
rect.Pos(), color ?? Color.SKYBLUE, fontSize, spacing, text);

protected override void UpdateCall()
{
if (!isVisible) return;
Expand Down

0 comments on commit d70fd33

Please sign in to comment.