Functioning state before changing to using render targets
This commit is contained in:
@@ -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<Texture2D>("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)
|
||||
|
@@ -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)
|
||||
|
13
RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs
Normal file
13
RhythmBullet/Zer01HD/Utilities/UI/Interactive/BasicButton.cs
Normal file
@@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -12,10 +12,7 @@ namespace RhythmBullet.Zer01HD.Utilities.UI
|
||||
|
||||
public class Screen
|
||||
{
|
||||
public virtual Vector2 ScreenSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public Rectangle ScreenSize;
|
||||
|
||||
ScreenState state;
|
||||
|
||||
|
Reference in New Issue
Block a user