Integrating the functioning camera and rectangle renderer.

This commit is contained in:
2019-02-25 21:40:07 -06:00
parent 99e4530407
commit 653a7de562
4 changed files with 54 additions and 26 deletions

View File

@@ -10,8 +10,7 @@ namespace RhythmBullet.Audio.Visualizer
internal class HorizontalVisualizer : UIModule, IDisposable
{
bool disposed;
private PrimitiveBatch primitiveBatch;
private RectangleRenderer renderer;
private RectangleRenderer rectangleRenderer;
private const int BAR_COUNT = 70;
private const int SMOOTH_RANGE = 3;
private readonly int binsPerBar;
@@ -29,8 +28,7 @@ namespace RhythmBullet.Audio.Visualizer
binsPerBar = tsp.GetCurrentSpectrum().Length / BAR_COUNT;
barValue = new int[BAR_COUNT];
primitiveBatch = new PrimitiveBatch(camera2D);
renderer = new RectangleRenderer(primitiveBatch);
rectangleRenderer = new RectangleRenderer();
}
public override void Update(GameTime gameTime)
@@ -44,18 +42,19 @@ namespace RhythmBullet.Audio.Visualizer
public override void Draw(SpriteBatch batch)
{
if (disposed) throw new ObjectDisposedException(this.Name);
rectangleRenderer.Begin(true);
for (int i = 0; i < BAR_COUNT; i++)
{
bar.X = (i * (bar.Width + spaceBetweenBars)) + bounds.X;
bar.Y = bounds.Y;
renderer.Begin(true);
bar.Height = barValue[i];
renderer.DrawRectangle(bar.X, bar.Y, bar.Width, bar.Height, color);
rectangleRenderer.Draw(bar.X, bar.Y, bar.Width, bar.Height, color);
bar.Height = -barValue[BAR_COUNT - i - 1];
renderer.DrawRectangle(bar.X, bar.Y, bar.Width, bar.Height, color);
rectangleRenderer.Draw(bar.X, bar.Y, bar.Width, bar.Height, color);
}
rectangleRenderer.End();
base.Draw(batch);
}
@@ -112,7 +111,7 @@ namespace RhythmBullet.Audio.Visualizer
{
if (disposing && !disposed)
{
primitiveBatch.Dispose();
rectangleRenderer.Dispose();
}
disposed = true;
}

View File

@@ -16,10 +16,9 @@ namespace RhythmBullet.Screens.MainMenu
TextButton playButton;
TextButton quitButton;
PrimitiveBatch primitiveBatch = new PrimitiveBatch();
internal MainPage() : base(0, 0)
{
Debugging = true;
}
protected override void Initialize(ContentManagerController assets, ISkin skin)
@@ -39,9 +38,6 @@ namespace RhythmBullet.Screens.MainMenu
public override void ApplySize(int width, int height)
{
title.Scale = (width - 40) / title.Texture.Width;
title.CenterOrigin();
title.bounds.X = (int)(width / 2f);
title.bounds.Y = (int)(height / 2f);
base.ApplySize(width, height);
}
@@ -49,10 +45,6 @@ namespace RhythmBullet.Screens.MainMenu
public override void Draw(SpriteBatch batch)
{
base.Draw(batch);
primitiveBatch.Begin(PrimitiveType.LineList);
primitiveBatch.AddVertex(new Vector2(20, 20), Color.Red);
primitiveBatch.AddVertex(new Vector2(50, 60), Color.Red);
primitiveBatch.End();
}
}
}