Skip to content

Commit

Permalink
Added How-To-Play info screen at the beginning of the game
Browse files Browse the repository at this point in the history
  • Loading branch information
ShyRed committed Apr 2, 2016
1 parent 051f6a6 commit 865fd11
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
4 changes: 4 additions & 0 deletions BreakoutParty/BreakoutParty.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<Compile Include="Gamestates\Gamestate.cs" />
<Compile Include="Gamestates\GamestateManager.cs" />
<Compile Include="Gamestates\HighscoreState.cs" />
<Compile Include="Gamestates\HowToPlayState.cs" />
<Compile Include="Gamestates\MainMenuGamestate.cs" />
<Compile Include="Gamestates\OptionsState.cs" />
<Compile Include="InputActions.cs" />
Expand Down Expand Up @@ -140,6 +141,9 @@
<Content Include="Content\GameOver.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\HowToPlay.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\LevelUp.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
2 changes: 1 addition & 1 deletion BreakoutParty/BreakoutPartyGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected override void Initialize()
Batch = new SpriteBatch(Graphics.GraphicsDevice);
AudioManager = new SoundManager(this);
GameManager = new GamestateManager(this);
GameManager.Add(new MainMenuGamestate());
GameManager.Add(new HowToPlayState());
}

/// <summary>
Expand Down
Binary file added BreakoutParty/Content/HowToPlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions BreakoutParty/Gamestates/HowToPlayState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using BreakoutParty.Sounds;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BreakoutParty.Gamestates
{
/// <summary>
/// "How To Play" information screen.
/// </summary>
sealed class HowToPlayState : Gamestate
{
/// <summary>
/// <see cref="SpriteBatch"/> for drawing.
/// </summary>
private SpriteBatch _Batch;

/// <summary>
/// Texture showing how to play.
/// </summary>
private Texture2D _HowToPlayTexture;

/// <summary>
/// Initializes the <see cref="Gamestate"/>.
/// </summary>
public override void Initialize()
{
_Batch = Manager.Game.Batch;
_HowToPlayTexture = Manager.Game.Content.Load<Texture2D>("HowToPlay");
Manager.Game.AudioManager.Play(MusicTracks.TitleMusic);
}

/// <summary>
/// Destroys the <see cref="Gamestate"/>.
/// </summary>
public override void Destroy()
{

}

/// <summary>
/// Updates the <see cref="Gamestate"/>.
/// </summary>
/// <param name="gameTime">Timing information.</param>
public override void Update(GameTime gameTime)
{
if (InputManager.IsActionPressed(PlayerIndex.One, InputActions.Ok)
|| InputManager.IsActionPressed(PlayerIndex.One, InputActions.Abort))
{
Manager.Game.AudioManager.Play(SoundEffects.MenuValidate);
Manager.Remove(this);
Manager.Add(new MainMenuGamestate());
}
}

/// <summary>
/// Draws the <see cref="Gamestate"/>.
/// </summary>
/// <param name="gameTime">Timing information.</param>
/// <returns><c>True</c>, if the next gamestate may draw too.</returns>
public override bool Draw(GameTime gameTime)
{
_Batch.Begin(SpriteSortMode.Texture,
BlendState.NonPremultiplied,
SamplerState.PointClamp,
DepthStencilState.None,
RasterizerState.CullNone);

_Batch.Draw(_HowToPlayTexture, Vector2.Zero, Color.White);

_Batch.End();

return false;
}
}
}

0 comments on commit 865fd11

Please sign in to comment.