Skip to content

Commit

Permalink
Adds sprite flip to example
Browse files Browse the repository at this point in the history
  • Loading branch information
ezequias2d committed Mar 31, 2022
1 parent 7dbbde9 commit bd4bdb2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Peridot.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using StbImageSharp;
using System.Diagnostics;
using Rectangle = System.Drawing.Rectangle;
using Peridot;

var title = "Peridot.Demo";
var wci = new WindowCreateInfo(100, 100, 640, 480, WindowState.Normal, title);
Expand Down Expand Up @@ -70,7 +71,12 @@
if (ps == 0 || ps == 100)
neg = !neg;

sb.Draw(texture, default, source, Color.White, 0, new(-size.X / 6, 0), Vector2.One, 1f);
var options = ps >= 0 && ps < 25 ? SpriteOptions.None :
ps >= 25 && ps < 50 ? SpriteOptions.FlipVertically :
ps >= 50 && ps < 75 ? SpriteOptions.FlipVertically | SpriteOptions.FlipHorizontally :
SpriteOptions.FlipHorizontally;

sb.Draw(texture, default, source, Color.White, 0, new(-size.X / 6, 0), Vector2.One, options, 1f);

var s = font.MeasureString("Hello World!", 32);
var strScissor = new Rectangle(0, 0, (int)s.X, (int)s.Y * ps / 100);
Expand Down

0 comments on commit bd4bdb2

Please sign in to comment.