diff --git a/RhythmBullet/Content/Content.mgcb b/RhythmBullet/Content/Content.mgcb index 6d80f2c..bc2a38f 100644 --- a/RhythmBullet/Content/Content.mgcb +++ b/RhythmBullet/Content/Content.mgcb @@ -688,3 +688,15 @@ /processorParam:TextureFormat=Color /build:RhythmBullet.png +#begin loading_ring.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:loading_ring.png + diff --git a/RhythmBullet/Content/loading_ring.png b/RhythmBullet/Content/loading_ring.png new file mode 100644 index 0000000..03b2a86 Binary files /dev/null and b/RhythmBullet/Content/loading_ring.png differ diff --git a/RhythmBullet/RhythmBulletGame.cs b/RhythmBullet/RhythmBulletGame.cs index 7f9bc9b..de22331 100644 --- a/RhythmBullet/RhythmBulletGame.cs +++ b/RhythmBullet/RhythmBulletGame.cs @@ -65,7 +65,10 @@ namespace RhythmBullet previousScreen = value; Screen.Hide(); } + currentScreen = value; + currentScreen.ScreenSize.Width = graphics.PreferredBackBufferWidth; + currentScreen.ScreenSize.Height = graphics.PreferredBackBufferHeight; Screen.Show(); } } @@ -94,7 +97,7 @@ namespace RhythmBullet // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); QueueContent(); - Screen = new LoadingScreen(Content.Load("RhythmBullet"), 0.5f, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); + Screen = new LoadingScreen(Content.Load("RhythmBullet"), 0.7f, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); } /// @@ -130,7 +133,7 @@ namespace RhythmBullet case ScreenState.ExitTransition: if (Screen.ExitingTransition(gameTime.ElapsedGameTime.TotalSeconds, Assets.Done, ref BackgroundColor)) { - Screen = previousScreen != null ? previousScreen : new MainScreen(graphics.GraphicsDevice, BackgroundColor); + Screen = previousScreen != null ? previousScreen : new MainScreen(graphics.GraphicsDevice, BackgroundColor, Assets); } break; case ScreenState.Normal: @@ -166,7 +169,7 @@ namespace RhythmBullet Assets.UnloadAll(); QueueContent(); Screen.AssetLoadStateChange(true); - Screen = new LoadingScreen(Content.Load("loading_ring"), 0.4f, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); + Screen = new LoadingScreen(Content.Load("loading_ring"), 0.3f, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), true); } private void PostResize() diff --git a/RhythmBullet/Zer01HD/Game/Screens/MainScreen.cs b/RhythmBullet/Zer01HD/Game/Screens/MainScreen.cs index 9b75a45..7751ad0 100644 --- a/RhythmBullet/Zer01HD/Game/Screens/MainScreen.cs +++ b/RhythmBullet/Zer01HD/Game/Screens/MainScreen.cs @@ -2,6 +2,7 @@ using Microsoft.Xna.Framework.Graphics; using RhythmBullet.Zer01HD.Game.Screens.Transitions; using RhythmBullet.Zer01HD.UI; +using RhythmBullet.Zer01HD.Utilities.ContentSystem; using RhythmBullet.Zer01HD.Utilities.UI; using System; using System.Collections.Generic; @@ -13,11 +14,26 @@ namespace RhythmBullet.Zer01HD.Game.Screens { class MainScreen : Screen { + Texture2D background; FadeInTransition fadeInTransition; - public MainScreen(GraphicsDevice graphicsDevice, Color transitionFromColor) : base(true) + public MainScreen(GraphicsDevice graphicsDevice, Color transitionFromColor, ContentSystem assets) : base(true) { - fadeInTransition = new FadeInTransition(graphicsDevice, transitionFromColor, ScreenSize); + fadeInTransition = new FadeInTransition(graphicsDevice, transitionFromColor); + background = assets.Get("backgrounds/mainBG"); + } + + public override void Show() + { + fadeInTransition.Init(ScreenSize); + base.Show(); + } + + public override void Draw(SpriteBatch spriteBatch) + { + spriteBatch.Draw(background, ScreenSize, Color.White); + fadeInTransition.Draw(spriteBatch); + base.Draw(spriteBatch); } public override void EnteringTransition(double delta, bool assetsLoaded, ref Color backgroundColor) diff --git a/RhythmBullet/Zer01HD/Game/Screens/Transitions/FadeInTransition.cs b/RhythmBullet/Zer01HD/Game/Screens/Transitions/FadeInTransition.cs index c594a96..e7c1776 100644 --- a/RhythmBullet/Zer01HD/Game/Screens/Transitions/FadeInTransition.cs +++ b/RhythmBullet/Zer01HD/Game/Screens/Transitions/FadeInTransition.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using RhythmBullet.Zer01HD.Utilities.UI; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,36 +12,38 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions { internal class FadeInTransition : IDisposable { + private const float RATE = 0.3f; public readonly Texture2D curtain; - Rectangle curtainSize; - Color color; + public Rectangle curtainSize; + private Color color; private float progR, progG, progB, progA; - private float rR, rG, rB, rA; - private bool recorded; - - internal FadeInTransition(GraphicsDevice graphicsDevice, Color startColor, Vector2 dimensions) + private float rR, rG, rB, rA; + internal FadeInTransition(GraphicsDevice graphicsDevice, Color startColor) { curtain = new Texture2D(graphicsDevice, 1, 1); - curtain.SetData(new[] { startColor }); - curtainSize.Width = (int)dimensions.X; - curtainSize.Height = (int)dimensions.Y; + curtain.SetData(new[] { Color.White }); + color = startColor; } + internal void Init(Rectangle dimensions) + { + curtainSize = dimensions; + rR = (0 - color.R) / RATE; + rG = (0 - color.G) / RATE; + rB = (0 - color.B) / RATE; + rA = (0 - color.A) / RATE; + + progA = color.A; + progR = color.R; + progG = color.G; + progB = color.B; + } internal bool Fade(float deltaf) { if (progR > 0 || progG > 0 || progB > 0) { - if (!recorded) - { - rR = (0 - color.R) / 1f; - rG = (0 - color.G) / 1f; - rB = (0 - color.B) / 1f; - rA = (0 - color.A) / 1f; - recorded = true; - } - progR += rR * deltaf; progR = Math.Max(progR, 0); progG += rG * deltaf; @@ -55,7 +58,7 @@ namespace RhythmBullet.Zer01HD.Game.Screens.Transitions color.A = (byte)progA; return false; } - return true; + return false; } internal void Draw(SpriteBatch batch) diff --git a/RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs b/RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs new file mode 100644 index 0000000..2e963af --- /dev/null +++ b/RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace RhythmBullet.Zer01HD.Utilities.UI.Interactive +{ + class BasicButton + { + + } +} diff --git a/RhythmBullet/Zer01HD/Utilities/UI/LoadingScreen.cs b/RhythmBullet/Zer01HD/Utilities/UI/LoadingScreen.cs index fafffa6..7e264fe 100644 --- a/RhythmBullet/Zer01HD/Utilities/UI/LoadingScreen.cs +++ b/RhythmBullet/Zer01HD/Utilities/UI/LoadingScreen.cs @@ -9,6 +9,8 @@ namespace RhythmBullet.Zer01HD.Game { class LoadingScreen : Screen { + private const float ENTER_RATE = 2f; + private const float EXIT_RATE = 1f; readonly Texture2D texture; Color color; Rectangle textureBounds; @@ -53,9 +55,9 @@ namespace RhythmBullet.Zer01HD.Game { if (!recorded) { - rR = (Color.White.R - BGColor.R) / 2f; - rG = (Color.White.G - BGColor.G) / 2f; - rB = (Color.White.B - BGColor.B) / 2f; + rR = (Color.White.R - BGColor.R) / ENTER_RATE; + rG = (Color.White.G - BGColor.G) / ENTER_RATE; + rB = (Color.White.B - BGColor.B) / ENTER_RATE; recorded = true; } progR += rR * deltaf; @@ -85,7 +87,7 @@ namespace RhythmBullet.Zer01HD.Game } if (progC > 0) { - float rate = deltaf * 255 / 1f; + float rate = deltaf * 255 / EXIT_RATE; progC -= rate; progC = Math.Max(progC, 0); color.R = (byte)progC; diff --git a/RhythmBullet/Zer01HD/Utilities/UI/Screen.cs b/RhythmBullet/Zer01HD/Utilities/UI/Screen.cs index f040476..a2e3125 100644 --- a/RhythmBullet/Zer01HD/Utilities/UI/Screen.cs +++ b/RhythmBullet/Zer01HD/Utilities/UI/Screen.cs @@ -12,10 +12,7 @@ namespace RhythmBullet.Zer01HD.Utilities.UI public class Screen { - public virtual Vector2 ScreenSize - { - get; set; - } + public Rectangle ScreenSize; ScreenState state;