roughed out a title screen

This commit is contained in:
Dylan Wilson
2018-04-15 20:40:16 +10:00
parent d576a4c99b
commit 06adea2ddc
5 changed files with 23 additions and 9 deletions
+12
View File
@@ -85,3 +85,15 @@
/processorParam:Quality=Best
/build:pip.wav
#begin title-screen.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:title-screen.png
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+2 -1
View File
@@ -49,7 +49,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Screens\PongGameScreen.cs" />
<Compile Include="Screens\MagentaScreen.cs" />
<Compile Include="Screens\TitleScreen.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="MonoGame.Framework">
@@ -119,6 +119,7 @@
<Content Include="Content\paddleBlue.png" />
<Content Include="Content\paddleRed.png" />
<Content Include="Content\pip.wav" />
<Content Include="Content\title-screen.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MonoGame.Extended\MonoGame.Extended.csproj">
+2 -3
View File
@@ -170,7 +170,7 @@ namespace Pong.Screens
_ball.Position = new Vector2(ScreenWidth / 2f, ScreenHeight / 2f);
_ball.Velocity = new Vector2(_random.Next(2, 5) * -100, 100);
_leftScore++;
ScreenManager.LoadScreen(new MagentaScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black, 0.5f));
ScreenManager.LoadScreen(new TitleScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black, 0.5f));
}
if (_ball.Position.X < -halfWidth && _ball.Velocity.X < 0)
@@ -178,8 +178,7 @@ namespace Pong.Screens
_ball.Position = new Vector2(ScreenWidth / 2f, ScreenHeight / 2f);
_ball.Velocity = new Vector2(_random.Next(2, 5) * 100, 100);
_rightScore++;
ScreenManager.LoadScreen(new MagentaScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black, 0.5f));
ScreenManager.LoadScreen(new TitleScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black, 0.5f));
}
}
@@ -7,11 +7,12 @@ using MonoGame.Extended.Screens.Transitions;
namespace Pong.Screens
{
public class MagentaScreen : GameScreen
public class TitleScreen : GameScreen
{
private SpriteBatch _spriteBatch;
private Texture2D _background;
public MagentaScreen(Game game)
public TitleScreen(Game game)
: base(game)
{
game.IsMouseVisible = true;
@@ -21,6 +22,7 @@ namespace Pong.Screens
{
base.LoadContent();
_spriteBatch = new SpriteBatch(GraphicsDevice);
_background = Content.Load<Texture2D>("title-screen");
}
public override void Update(GameTime gameTime)
@@ -28,15 +30,15 @@ namespace Pong.Screens
var mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed)
ScreenManager.LoadScreen(new PongGameScreen(Game), new ExpandTransition(GraphicsDevice, Color.Black, 0.5f));
ScreenManager.LoadScreen(new PongGameScreen(Game), new FadeTransition(GraphicsDevice, Color.Black, 0.5f));
}
public override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Magenta);
_spriteBatch.Begin();
_spriteBatch.FillRectangle(new RectangleF(100, 200, 300, 400), Color.AliceBlue);
_spriteBatch.Begin(samplerState: SamplerState.PointClamp);
_spriteBatch.Draw(_background, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White);
_spriteBatch.End();
}
}