smoothed out black to white transition on splash screen

This commit is contained in:
Harrison Deng 2018-10-31 18:21:44 -05:00
parent b77aa6d7fd
commit 46dc862aed
3 changed files with 18 additions and 12 deletions

View File

@ -34,7 +34,7 @@ namespace RhythmBullet
public RhythmBulletGame() public RhythmBulletGame()
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
BackgroundColor = new Color(0, 0, 0, 255);
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
Assets = new ContentSystem(Content); Assets = new ContentSystem(Content);
resolutionContentResolver = new ResolutionContentResolver(); resolutionContentResolver = new ResolutionContentResolver();
@ -91,7 +91,7 @@ namespace RhythmBullet
// Create a new SpriteBatch, which can be used to draw textures. // Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice); spriteBatch = new SpriteBatch(GraphicsDevice);
QueueContent(); QueueContent();
Screen = new SplashScreen(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); Screen = new LoadingScreen(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
} }
/// <summary> /// <summary>
@ -139,6 +139,7 @@ namespace RhythmBullet
public void Resize(int width, int height) public void Resize(int width, int height)
{ {
pixels_per_WU = height / WORLD_HEIGHT;
resolutionContentResolver.Width = width; resolutionContentResolver.Width = width;
resolutionContentResolver.Height = height; resolutionContentResolver.Height = height;
graphics.PreferredBackBufferWidth = width; graphics.PreferredBackBufferWidth = width;
@ -147,7 +148,7 @@ namespace RhythmBullet
Assets.UnloadAll(); Assets.UnloadAll();
QueueContent(); QueueContent();
Screen.AssetLoadStateChange(true); Screen.AssetLoadStateChange(true);
Screen = new SplashScreen(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); Screen = new LoadingScreen(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight));
} }
private void PostResize() private void PostResize()

View File

@ -131,6 +131,7 @@ namespace RhythmBullet.Zer01HD.Utilities.ContentSystem
contentManager.Unload(); contentManager.Unload();
assets.Clear(); assets.Clear();
ClearQueue(); ClearQueue();
Debug.WriteLine("Unloaded all assets.");
} }
} }

View File

@ -12,15 +12,18 @@ using System.Threading.Tasks;
namespace RhythmBullet.Zer01HD.Game namespace RhythmBullet.Zer01HD.Game
{ {
class SplashScreen : Screen class LoadingScreen : Screen
{ {
Texture2D recrown; Texture2D recrown;
Color color;
Rectangle rectangleBounds; Rectangle rectangleBounds;
float proportion = 0.4f; float proportion = 0.4f;
RhythmBulletGame rhythmBullet; RhythmBulletGame rhythmBullet;
float progress; double progress;
public SplashScreen(RhythmBulletGame rhythmBullet, Rectangle dimensions) double timePassed;
public LoadingScreen(RhythmBulletGame rhythmBullet, Rectangle dimensions)
{ {
color = Color.White;
this.recrown = rhythmBullet.Content.Load<Texture2D>("RhythmBullet"); this.recrown = rhythmBullet.Content.Load<Texture2D>("RhythmBullet");
this.rhythmBullet = rhythmBullet; this.rhythmBullet = rhythmBullet;
rectangleBounds = new Rectangle(0, 0, (int)(dimensions.Height * proportion), (int)(dimensions.Height * proportion)); rectangleBounds = new Rectangle(0, 0, (int)(dimensions.Height * proportion), (int)(dimensions.Height * proportion));
@ -31,13 +34,14 @@ namespace RhythmBullet.Zer01HD.Game
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
if (progress < 0.8f) if (progress < 1f)
{ {
float delta = (float) gameTime.ElapsedGameTime.TotalSeconds; double delta = gameTime.ElapsedGameTime.TotalSeconds;
progress += (delta/6f); timePassed += delta;
if (progress > 1f) progress = timePassed / 4;
if (progress > 0.9f)
{ {
progress = 1f; progress = 0.9f;
} }
rhythmBullet.BackgroundColor.R = (byte)(progress * 255); rhythmBullet.BackgroundColor.R = (byte)(progress * 255);
rhythmBullet.BackgroundColor.G = (byte)(progress * 255); rhythmBullet.BackgroundColor.G = (byte)(progress * 255);
@ -49,7 +53,7 @@ namespace RhythmBullet.Zer01HD.Game
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
{ {
spriteBatch.Draw(recrown, rectangleBounds, Color.White); spriteBatch.Draw(recrown, rectangleBounds, color);
base.Draw(spriteBatch); base.Draw(spriteBatch);
} }
} }