From 9a25f068fc31eaba93d8b0d28965c6b87d81fe82 Mon Sep 17 00:00:00 2001 From: quinnvoker Date: Sat, 17 Nov 2018 20:54:01 -0800 Subject: [PATCH] Restructured Solution Layout Moved several enums and helper classes into the QURO library for flexibility and potential reuse. Also solved desync in animations by making AnimatedSprites reset their timer every time a new animation is loaded. --- AnimationGenerator/AnimationGenerator.csproj | 6 +++++- AnimationGenerator/Program.cs | 21 ++++++++++--------- PuzzSwap.sln | 8 ++++++- .../AnimatedSprite.cs | 12 ++++++++++- .../Animation.cs | 0 .../AnimationSet.cs | 0 .../Frame.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../QURO.AnimationLibrary.csproj | 6 ++++++ 9 files changed, 40 insertions(+), 13 deletions(-) rename {AnimationLibrary => QURO.AnimationLibrary}/AnimatedSprite.cs (84%) rename {AnimationLibrary => QURO.AnimationLibrary}/Animation.cs (100%) rename {AnimationLibrary => QURO.AnimationLibrary}/AnimationSet.cs (100%) rename {AnimationLibrary => QURO.AnimationLibrary}/Frame.cs (100%) rename {AnimationLibrary => QURO.AnimationLibrary}/Properties/AssemblyInfo.cs (100%) rename {AnimationLibrary => QURO.AnimationLibrary}/QURO.AnimationLibrary.csproj (92%) diff --git a/AnimationGenerator/AnimationGenerator.csproj b/AnimationGenerator/AnimationGenerator.csproj index d249b5e..2c4eaeb 100644 --- a/AnimationGenerator/AnimationGenerator.csproj +++ b/AnimationGenerator/AnimationGenerator.csproj @@ -56,10 +56,14 @@ - + {69dadc27-fbeb-4625-9212-6eb5bed5102a} QURO.AnimationLibrary + + {4581e0c8-b14a-454d-9a7b-52d37535e7e9} + QURO + diff --git a/AnimationGenerator/Program.cs b/AnimationGenerator/Program.cs index 32bc993..4ac10d6 100644 --- a/AnimationGenerator/Program.cs +++ b/AnimationGenerator/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; +using QURO; using QURO.AnimationLibrary; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate; @@ -26,15 +27,15 @@ namespace AnimationGenerator Frame[] soloCursor_pulse_frames = new Frame[] { - new Frame(loadedFrames["soloCursor"], 20f / 60f), - new Frame(loadedFrames["soloCursor_pulse"], 20f / 60f), + new Frame(loadedFrames["soloCursor"], FrameTime.FramesToSeconds(20)), + new Frame(loadedFrames["soloCursor_pulse"], FrameTime.FramesToSeconds(20)), }; output.Add(new Animation("soloCursor_pulse", soloCursor_pulse_frames, true)); Frame[] twinCursor_pulse_frames = new Frame[] { - new Frame(loadedFrames["twinCursor"], 20f / 60f), - new Frame(loadedFrames["twinCursor_pulse"], 20f / 60f), + new Frame(loadedFrames["twinCursor"], FrameTime.FramesToSeconds(20)), + new Frame(loadedFrames["twinCursor_pulse"], FrameTime.FramesToSeconds(20)), }; output.Add(new Animation("twinCursor_pulse", twinCursor_pulse_frames, true)); @@ -73,12 +74,12 @@ namespace AnimationGenerator Frame[] block_bounce_frames = new Frame[] { - new Frame(loadedFrames["block0_bounce2"], 1f / 60f), - new Frame(loadedFrames["block0"], 1f / 60f), - new Frame(loadedFrames["block0_squish"], 1f / 60f), - new Frame(loadedFrames["block0"], 1f / 60f), - new Frame(loadedFrames["block0_bounce1"], 2f / 60f), - new Frame(loadedFrames["block0"], 1f / 60f), + new Frame(loadedFrames["block0_bounce2"], FrameTime.FramesToSeconds(1)), + new Frame(loadedFrames["block0"], FrameTime.FramesToSeconds(1)), + new Frame(loadedFrames["block0_squish"], FrameTime.FramesToSeconds(1)), + new Frame(loadedFrames["block0"], FrameTime.FramesToSeconds(1)), + new Frame(loadedFrames["block0_bounce1"], FrameTime.FramesToSeconds(2)), + new Frame(loadedFrames["block0"], FrameTime.FramesToSeconds(0)), }; output.Add(new Animation("block_bounce", block_bounce_frames, false)); diff --git a/PuzzSwap.sln b/PuzzSwap.sln index 025044d..d5a764c 100644 --- a/PuzzSwap.sln +++ b/PuzzSwap.sln @@ -5,10 +5,12 @@ VisualStudioVersion = 15.0.27703.2047 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PuzzSwap", "PuzzSwap\PuzzSwap.csproj", "{CD753795-0CB4-4F05-A0E7-2D2EFC968D82}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO.AnimationLibrary", "QURO.AnimationLibrary\QURO.AnimationLibrary.csproj", "{69DADC27-FBEB-4625-9212-6EB5BED5102A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationGenerator", "AnimationGenerator\AnimationGenerator.csproj", "{B1938BD7-A474-427F-91F1-F8A1875B28CE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QURO", "QURO\QURO.csproj", "{4581E0C8-B14A-454D-9A7B-52D37535E7E9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {B1938BD7-A474-427F-91F1-F8A1875B28CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {B1938BD7-A474-427F-91F1-F8A1875B28CE}.Release|Any CPU.Build.0 = Release|Any CPU + {4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4581E0C8-B14A-454D-9A7B-52D37535E7E9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AnimationLibrary/AnimatedSprite.cs b/QURO.AnimationLibrary/AnimatedSprite.cs similarity index 84% rename from AnimationLibrary/AnimatedSprite.cs rename to QURO.AnimationLibrary/AnimatedSprite.cs index a347414..eee4d3c 100644 --- a/AnimationLibrary/AnimatedSprite.cs +++ b/QURO.AnimationLibrary/AnimatedSprite.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using QURO; namespace QURO.AnimationLibrary { @@ -13,13 +14,16 @@ namespace QURO.AnimationLibrary set { currentAnimation = value; + finishedPlaying = false; CurrentFrameIndex = 0; + timer = CurrentFrame.Delay; } } public int CurrentFrameIndex { get; set; } public Frame CurrentFrame => CurrentAnimation.Frames[CurrentFrameIndex]; private float timer; + private bool finishedPlaying; public AnimatedSprite() { } @@ -28,17 +32,19 @@ namespace QURO.AnimationLibrary SpriteSheet = spriteSheet; CurrentAnimation = startingAnimation; timer = CurrentFrame.Delay; + finishedPlaying = false; } public void Reset() { CurrentFrameIndex = 0; + finishedPlaying = false; timer = CurrentFrame.Delay; } public void Update(GameTime gameTime) { - if (!CurrentAnimation.IsStillImage) + if (!CurrentAnimation.IsStillImage && !finishedPlaying) { if (timer <= 0) { @@ -52,6 +58,10 @@ namespace QURO.AnimationLibrary { CurrentFrameIndex = 0; } + else + { + finishedPlaying = true; + } } timer = CurrentFrame.Delay; } diff --git a/AnimationLibrary/Animation.cs b/QURO.AnimationLibrary/Animation.cs similarity index 100% rename from AnimationLibrary/Animation.cs rename to QURO.AnimationLibrary/Animation.cs diff --git a/AnimationLibrary/AnimationSet.cs b/QURO.AnimationLibrary/AnimationSet.cs similarity index 100% rename from AnimationLibrary/AnimationSet.cs rename to QURO.AnimationLibrary/AnimationSet.cs diff --git a/AnimationLibrary/Frame.cs b/QURO.AnimationLibrary/Frame.cs similarity index 100% rename from AnimationLibrary/Frame.cs rename to QURO.AnimationLibrary/Frame.cs diff --git a/AnimationLibrary/Properties/AssemblyInfo.cs b/QURO.AnimationLibrary/Properties/AssemblyInfo.cs similarity index 100% rename from AnimationLibrary/Properties/AssemblyInfo.cs rename to QURO.AnimationLibrary/Properties/AssemblyInfo.cs diff --git a/AnimationLibrary/QURO.AnimationLibrary.csproj b/QURO.AnimationLibrary/QURO.AnimationLibrary.csproj similarity index 92% rename from AnimationLibrary/QURO.AnimationLibrary.csproj rename to QURO.AnimationLibrary/QURO.AnimationLibrary.csproj index 2dde226..d8cffa6 100644 --- a/AnimationLibrary/QURO.AnimationLibrary.csproj +++ b/QURO.AnimationLibrary/QURO.AnimationLibrary.csproj @@ -51,5 +51,11 @@ + + + {4581e0c8-b14a-454d-9a7b-52d37535e7e9} + QURO + + \ No newline at end of file