</Compile>
</ItemGroup>
<ItemGroup>
- <Folder Include="Sound\" />
+ <Compile Include="Graphics\pause-screen.png">
+ <Name>pause-screen</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Graphics\circle.png">
<Processor>FontDescriptionProcessor</Processor>
</Compile>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Sound\polaritytheme.wav">
+ <Name>polaritytheme</Name>
+ <Importer>WavImporter</Importer>
+ <Processor>SongProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Graphics\polaritydemotitle.png">
+ <Name>polaritydemotitle</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Fonts\bigfont.png">
+ <Name>bigfont</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>FontTextureProcessor</Processor>
+ </Compile>
+ <Compile Include="Fonts\smallfont.png">
+ <Name>smallfont</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>FontTextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
mainShip.Initialize(Game.Content.Load<Texture2D>("Graphics\\main-ship"), position);
ActorManager.CheckIn(mainShip);
- Renderer.CheckIn(mainShip);
return mainShip;
}
ship.SetPolarity(polarity);
ActorManager.CheckIn(ship);
- Renderer.CheckIn(ship);
return ship;
}
bullet.Angle = angle;
ActorManager.CheckIn(bullet);
- Renderer.CheckIn(bullet);
return bullet;
}
ship.BoxDimensions.Z = 10;
ship.Initialize(texture, position);
- ship.MaxVelocity = 5.5f;
+ ship.MaxVelocity = 5.2f;
ship.FleeVelocity = 6.5f;
ship.ChargeVelocity = 5.5f;
ship.Value = 3;
ship.SetPolarity(polarity);
ActorManager.CheckIn(ship);
- Renderer.CheckIn(ship);
return ship;
}
ship.BoxDimensions.Z = 40;
ship.Initialize(texture, position);
+ ship.MagneticRadius = 1000;
+ ship.RepelRadius = 200;
ship.MaxVelocity = 0.5f;
ship.FleeVelocity = 5;
ship.ChargeVelocity = 1;
ship.Value = 10;
- ship.HP = 9;
+ ship.HP = 29;
ship.SetPolarity(polarity);
ActorManager.CheckIn(ship);
- Renderer.CheckIn(ship);
return ship;
}
static public void CheckOut(Actor actor)
{
+ actor.CleanUp();
Actors.Remove(actor);
+ actor = null;
}
static public void Update(GameTime gameTime)
if (i >= Actors.Count) {
i = Actors.Count - 1;
}
+
+ if (Actors.Count == 0)
+ {
+ return;
+ }
+
Actor actor = Actors[i];
for (var j = i - 1; j >= 0; j--)
{
actor.Position.Y > Game.GraphicsDevice.Viewport.Height + OutlierBounds)
{
CheckOut(actor);
+ if (actor.Parent != null)
+ {
+ actor.Parent.Children.Remove(actor);
+ }
}
}
}
+ static public void Empty()
+ {
+ foreach (Actor actor in Actors) {
+ actor.CleanUp();
+ }
+ Actors.Clear();
+ }
+
internal static void SetGame(SuperPolarity game)
{
Game = game;
}
+
+ public static void Bomb()
+ {
+ for (var i = Actors.Count - 1; i >= 0; i--)
+ {
+ var actor = Actors[i];
+ if (actor.GetType() == typeof(StandardShip))
+ {
+ CheckOut(actor);
+ Renderer.CheckOut(actor);
+ }
+ }
+ }
+
+ public static int CountBaddies()
+ {
+ return Actors.Where(a => a.GetType() == typeof(StandardShip)).Count();
+ }
}
}
public virtual void Draw(SpriteBatch spriteBatch)
{
- foreach (Actor child in Children)
+ Actor child = null;
+
+ // TODO: Check what's up with the null children.
+ if (Children == null)
{
+ return;
+ }
+ for (var i = Children.Count - 1; i >= 0; i--)
+ {
+ child = Children[i];
child.Draw(spriteBatch);
}
spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f);
- spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25));
+ //spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25));
}
void CheckOutliers()
{
Dying = true;
}
+
+ public virtual void CleanUp()
+ {
+ Texture = null;
+ BoxTexture = null;
+ Children = null;
+ Texture = null;
+ }
}
}
Renderer.CheckOut(this);
Parent.Children.Remove(this);
}
+
+ public override void CleanUp()
+ {
+ base.CleanUp();
+ this.particleEngine = null;
+ }
}
}
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Audio;
namespace SuperPolarity
{
protected float MaxImmortalTime;
protected bool Flashing;
+ protected SoundEffect PolarityChange;
+ protected SoundEffect ShootSound;
+ protected SoundEffect Hit;
+
public MainShip(SuperPolarity newGame) : base(newGame) {}
~MainShip()
{
base.Initialize(texture, position);
- MainShip.BlueColor = new Color(230, 244, 249);
- MainShip.RedColor = new Color(255, 234, 241);
+ MainShip.BlueColor = new Color(0, 184, 229);
+ MainShip.RedColor = new Color(201, 0, 68);
+
+ PolarityChange = game.Content.Load<SoundEffect>("Sound\\polaritychange");
+ ShootSound = game.Content.Load<SoundEffect>("Sound\\bullet");
+ Hit = game.Content.Load<SoundEffect>("Sound\\hit");
InitParticleEngine();
SetPolarity(Polarity.Positive);
+ ActVelocity = 2.5f;
+
ShotCooldown = 50;
MaxImmortalTime = 1500;
protected void HandleShot(float value)
{
+
+ Shooting = true;
+ Timer t = new Timer(new TimerCallback(UnlockShot));
+ t.Change(ShotCooldown, Timeout.Infinite);
+
+ if (Children.Count > 10)
+ {
+ return;
+ }
+
var bullet = ActorFactory.CreateBullet(Position, Angle);
Children.Add(bullet);
bullet.Parent = this;
- Shooting = true;
- Timer t = new Timer(new TimerCallback(UnlockShot));
- t.Change(ShotCooldown, Timeout.Infinite);
+ ShootSound.Play();
}
protected void UnlockShot(object state)
{
InputController.Unlock("shoot");
+ Shooting = false;
}
protected void HandleChangePolarity(float value)
public void HandleHorizontalMovement(float value)
{
- Acceleration.X = value * AccelerationRate;
-
- if (value > 0.1 && Velocity.X < 0 || value < 0.1 && Velocity.X > 0)
+ if (value >= -0.5 && value <= 0.5)
{
- Acceleration.X *= 2;
+ value = 0;
}
- if (value > 0.1 && Velocity.Y < 0 || value < 0.1 && Velocity.Y > 0)
- {
- Acceleration.Y *= 2;
- }
+ Velocity.X = value * MaxVelocity;
}
public void HandleVerticalMovement(float value)
{
- Acceleration.Y = value * AccelerationRate;
+ if (value >= -0.5 && value <= 0.5)
+ {
+ value = 0;
+ }
+
+ Velocity.Y = value * MaxVelocity;
}
public override void SwitchPolarity()
{
base.SwitchPolarity();
SwitchParticleEngine(CurrentPolarity);
+ PolarityChange.Play();
game.Player.ResetMultiplier();
}
particleEngine.Update();
ConstrainToEdges();
UpdateImmortality(gameTime);
- Shooting = false;
}
public void UpdateImmortality(GameTime gameTime)
public override void Move(GameTime gameTime)
{
- base.Move(gameTime);
+ var VelocityLimit = MaxVelocity;
+ var SavedVelocity = new Vector2(Velocity.X, Velocity.Y);
if (Shooting)
{
- if (Velocity.X > ActVelocity)
- {
- Velocity.X = ActVelocity;
- }
+ VelocityLimit = ActVelocity;
+ }
- if (Velocity.X < -ActVelocity)
- {
- Velocity.X = -ActVelocity;
- }
+ if (SavedVelocity.X > VelocityLimit)
+ {
+ SavedVelocity.X = VelocityLimit;
+ }
- if (Velocity.Y > ActVelocity)
- {
- Velocity.Y = ActVelocity;
- }
+ if (SavedVelocity.X < -VelocityLimit)
+ {
+ SavedVelocity.X = -VelocityLimit;
+ }
- if (Velocity.Y < -ActVelocity)
- {
- Velocity.Y = -ActVelocity;
- }
+ if (SavedVelocity.Y > VelocityLimit)
+ {
+ SavedVelocity.Y = VelocityLimit;
+ }
+
+ if (SavedVelocity.Y < -VelocityLimit)
+ {
+ SavedVelocity.Y = -VelocityLimit;
}
+
+ Position.X = Position.X + SavedVelocity.X;
+ Position.Y = Position.Y + SavedVelocity.Y;
}
public override void Magnetize(Ship ship, float distance, float angle)
if (game.Player.Lives < 0)
{
Dying = true;
+ game.GameOver();
}
else {
+ Hit.Play();
Immortal = true;
CurrentImmortalTime = 0;
}
}
+
+ public override void CleanUp()
+ {
+ base.CleanUp();
+ particleEngine = null;
+ InputController.Unbind("moveX", HandleHorizontalMovement);
+ InputController.Unbind("moveY", HandleVerticalMovement);
+ InputController.Unbind("changePolarity", HandleChangePolarity);
+ InputController.Unbind("shoot", HandleShot);
+ }
}
}
public float FleeVelocity;
public float ActVelocity;
public float ChargeVelocity;
- protected int RepelRadius;
+ public int RepelRadius;
protected bool Magnetizing;
Rate = rate;
Randomizer = new Random();
Position = position;
+ CurrentTime = rate;
}
public void Update(GameTime gameTime)
{
- if (Game.Player.Score > ScoreThreshold)
+ if (ActorManager.CountBaddies() > 50)
+ {
+ return;
+ }
+
+ if (Game.Player.Score >= ScoreThreshold)
{
CurrentTime = CurrentTime + gameTime.ElapsedGameTime.Milliseconds;
if (ShipType == Ships.Ship)
{
- ActorFactory.CreateShip(polarity, Position);
+ Renderer.CheckIn(ActorFactory.CreateShip(polarity, Position));
}
if (ShipType == Ships.Scout)
{
- ActorFactory.CreateScout(polarity, Position);
+ Renderer.CheckIn(ActorFactory.CreateScout(polarity, Position));
}
if (ShipType == Ships.Battlecruiser)
{
- ActorFactory.CreateCruiser(polarity, Position);
+ Renderer.CheckIn(ActorFactory.CreateCruiser(polarity, Position));
}
}
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Audio;
+using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Input;
namespace SuperPolarity
{
public GameScreen(SuperPolarity newGame) : base(newGame) {}
- private BasicGenerator generatorTest;
+ protected List<BasicGenerator> Generators;
+
+ protected int LivesRate;
+ protected int CurrentLivesRate;
+ protected int BombRate;
+ protected int CurrentBombRate;
+ protected SoundEffect BombSound;
+ protected SoundEffect LifeSound;
+
+ protected bool Flashing;
+
+ protected bool IsPaused;
+ protected Texture2D PauseScreen;
public override void Initialize()
{
+ Generators = new List<BasicGenerator>();
+
+ CurrentBombRate = 1;
+ BombRate = 6000;
+
+ LivesRate = 10000;
+ CurrentLivesRate = 1;
+
InputController.RegisterEventForButton("changePolarity", Buttons.A);
InputController.RegisterEventForKey("changePolarity", Keys.Z);
InputController.RegisterEventForButton("shoot", Buttons.X);
InputController.RegisterEventForKey("shoot", Keys.X);
+
+ InputController.Bind("pause", HandlePause);
+
+ PauseScreen = Game.Content.Load<Texture2D>("Graphics\\pause-screen");
+ }
+
+ protected void HandlePause(float value)
+ {
+ Console.WriteLine("Paused");
+ IsPaused = !IsPaused;
+
+ if (IsPaused)
+ {
+ MediaPlayer.Volume = 0.05f;
+ }
+ else
+ {
+ MediaPlayer.Volume = 1;
+ }
}
public override void LoadContent()
{
+ CreateGenerators();
+
+ Vector2 playerPosition = new Vector2(Game.GraphicsDevice.Viewport.TitleSafeArea.X + Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.TitleSafeArea.Y + Game.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
- generatorTest = new BasicGenerator();
- generatorTest.Initialize(Game, new Vector2(100, 600), BasicGenerator.Ships.Scout, 3000, 10);
+ BombSound = Game.Content.Load<SoundEffect>("Sound\\bomb");
+ LifeSound = Game.Content.Load<SoundEffect>("Sound\\life");
- Vector2 playerPosition = new Vector2(Game.GraphicsDevice.Viewport.TitleSafeArea.X, Game.GraphicsDevice.Viewport.TitleSafeArea.Y + Game.GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
+ Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
- ActorFactory.CreateMainShip(playerPosition);
- ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200));
- ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200));
- ActorFactory.CreateScout(Ship.Polarity.Negative, new Vector2(500, 500));
- ActorFactory.CreateCruiser(Ship.Polarity.Positive, new Vector2(40, 40));
+ Game.PlaySong("game");
+ }
+
+ protected void CalculateBomb()
+ {
+ if (Game.Player.Score >= BombRate * CurrentBombRate)
+ {
+ ActorManager.Bomb();
+ Flashing = true;
+ BombSound.Play();
+ CurrentBombRate = CurrentBombRate + 1;
+ }
+ }
+
+ protected void CalculateLife()
+ {
+ if (Game.Player.Score >= LivesRate * CurrentLivesRate)
+ {
+ Game.Player.Lives = Game.Player.Lives + 1;
+ LifeSound.Play();
+ CurrentLivesRate = CurrentLivesRate + 1;
+ }
}
public override void Update(GameTime gameTime)
{
- InputController.UpdateInput();
+ CalculateBomb();
+ CalculateLife();
+ InputController.UpdateInput(IsPaused);
+ if (IsPaused)
+ {
+ return;
+ }
ActorManager.Update(gameTime);
- generatorTest.Update(gameTime);
+
+ foreach (BasicGenerator generator in Generators)
+ {
+ generator.Update(gameTime);
+ }
}
public override void Draw(SpriteBatch spriteBatch)
{
Renderer.Draw(spriteBatch);
+ Game.Player.Draw(spriteBatch);
+
+ if (IsPaused)
+ {
+ spriteBatch.Draw(PauseScreen, new Vector2(0, 0), Color.White);
+ }
+
+ if (Flashing)
+ {
+ Game.GraphicsDevice.Clear(Color.Black);
+ Flashing = false;
+ }
+ }
+
+ protected void CreateGenerators()
+ {
+ // The basic ship generators.
+ var gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(-50, -50), BasicGenerator.Ships.Ship, 3000, 0);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 0);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, -50), BasicGenerator.Ships.Ship, 3000, 0);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 0);
+ Generators.Add(gen);
+
+ // After 1.5k liberate some sporadic Scouts, and add two more ship generators.
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Ship, 3000, 1500);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 3000, 1500);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Scout, 6000, 1500);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Scout, 6000, 1500);
+ Generators.Add(gen);
+
+
+ // After 3k add more scouts.
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Scout, 3000, 3000);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Scout, 3000, 5000);
+ Generators.Add(gen);
+
+ // After 5k release more ships and a cruiser.
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, -50), BasicGenerator.Ships.Ship, 1500, 5000);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width / 2, Game.GraphicsDevice.Viewport.Height + 50), BasicGenerator.Ships.Ship, 1500, 5000);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(-50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Battlecruiser, 10000, 5000);
+ Generators.Add(gen);
+
+ gen = new BasicGenerator();
+ gen.Initialize(Game, new Vector2(Game.GraphicsDevice.Viewport.Width + 50, Game.GraphicsDevice.Viewport.Height / 2), BasicGenerator.Ships.Battlecruiser, 10000, 5000);
+ Generators.Add(gen);
+ }
+
+ public override void CleanUp()
+ {
+ base.CleanUp();
+ Generators.Clear();
+ InputController.Unbind("pause", HandlePause);
+ Renderer.Empty();
+ ActorManager.Empty();
}
}
}
public static void UpdateInput()
{
- Poll();
DispatchMoveEvents();
DispatchRegisteredEvents();
}
+ public static void UpdateInput(bool highPriorityOnly)
+ {
+ Poll();
+ DispatchPauseEvent();
+ if (!highPriorityOnly)
+ {
+ UpdateInput();
+ }
+ }
+
+ public static void DispatchPauseEvent()
+ {
+ // OK THIS IS ALL KINDS OF WRONG. THIS IS A PLACEHOLDER BECAUSE DEMO!
+ var keyPressed = false;
+ if ((InputKeyboardState.IsKeyDown(Keys.Enter) || InputGamePadState.IsButtonDown(Buttons.Start))) {
+ keyPressed = true;
+ if(!BlockedButtons.Contains("pause") && !BlockedKeys.Contains("pause"))
+ {
+ BlockedButtons.Add("pause");
+ BlockedKeys.Add("pause");
+ Console.WriteLine("Dispatch");
+ Dispatch("pause", 0);
+ }
+ }
+
+ if (!keyPressed)
+ {
+ BlockedButtons.Remove("pause");
+ BlockedKeys.Remove("pause");
+ }
+ }
+
private static void Poll()
{
InputGamePadState = GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One);
listenerList.Add(listener);
}
+ public static void Unbind(string eventName, Action<float> listener)
+ {
+ List<Action<float>> listenerList;
+ bool foundListeners;
+
+ if (!Listeners.ContainsKey(eventName))
+ {
+ return;
+ }
+
+ foundListeners = Listeners.TryGetValue(eventName, out listenerList);
+
+ listenerList.Remove(listener);
+ }
+
public static void Dispatch(string eventName, float value)
{
List<Action<float>> listenerList;
return;
}
- foreach (Action<float> method in listenerList)
+ for (var i = listenerList.Count - 1; i >= 0; i--)
{
- method(value);
+ listenerList[i](value);
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
namespace SuperPolarity
{
public int Multiplier;
public int Lives;
- public Player()
+
+ SpriteFont DebugFont;
+ SuperPolarity Game;
+
+ Texture2D LifeSprite;
+
+ public Player(SuperPolarity game)
{
Score = 0;
Multiplier = 1;
Lives = 3;
+ Game = game;
+ DebugFont = Game.Content.Load<SpriteFont>("Fonts\\bigfont");
+ LifeSprite = Game.Content.Load<Texture2D>("Graphics\\neutral-ship");
}
public void AddScore(int value)
Multiplier = 1;
}
- public void Draw()
+ public void Draw(SpriteBatch spriteBatch)
{
+ var UiColor = new Color(0, 0, 0, 200);
+ var lightColor = new Color(0, 0, 0, 128);
+ spriteBatch.DrawString(DebugFont, Score.ToString(), new Vector2(10, 10), UiColor);
+ spriteBatch.DrawString(DebugFont, "x" + Multiplier.ToString(), new Vector2(10, 30), lightColor);
+ var lifePosition = new Vector2(Game.GraphicsDevice.Viewport.Width - 120, 10);
+ if (Lives > 4)
+ {
+ spriteBatch.Draw(LifeSprite, lifePosition, null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
+ spriteBatch.DrawString(DebugFont, "x " + Lives.ToString(), new Vector2(lifePosition.X + 8, lifePosition.Y + 5), UiColor);
+ }
+ else
+ {
+ for (var i = 0; i < Lives; i++)
+ {
+ spriteBatch.Draw(LifeSprite, new Vector2(lifePosition.X + (i * 28), lifePosition.Y), null, UiColor, (float)(Math.PI / 2), Vector2.Zero, 0.5f, SpriteEffects.None, 0f);
+ }
+ }
}
public void Update()
{
}
+
+ public void Reset()
+ {
+ Score = 0;
+ Multiplier = 1;
+ Lives = 3;
+ }
}
}
actor.Draw(spriteBatch);
}
}
+
+ static public void Empty()
+ {
+ Actors.Clear();
+ }
}
}
class Screen
{
protected SuperPolarity Game;
+ public bool Active;
public Screen(SuperPolarity game)
{
+ Active = false;
Game = game;
}
static public void Push(Screen screen)
{
+ if (Screens.Count > 0)
+ {
+ Screens.Peek().Active = false;
+ }
+
+ screen.LoadContent();
+ screen.Active = true;
Screens.Push(screen);
}
static public void Pop()
{
- Screens.Pop();
+ var screen = Screens.Pop();
+ screen.Active = false;
+ screen.CleanUp();
+ Screens.Peek().Active = true;
}
static public void Update(GameTime gameTime)
static public void Draw(SpriteBatch spriteBatch)
{
- foreach (Screen screen in Screens)
- {
- screen.Draw(spriteBatch);
- }
+ Screens.Peek().Draw(spriteBatch);
}
internal static void SetGame(SuperPolarity game)
<Link>SDL.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <Content Include="Content\Sound\bomb.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\bullet.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\gameover.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\hit.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\life.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\polaritychange.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
+ <Content Include="Content\Sound\polaritytheme.wav">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
<Content Include="Icon.ico" />
</ItemGroup>
+ <ItemGroup />
<ItemGroup>
- <Folder Include="Content\Sound\" />
- </ItemGroup>
- <ItemGroup>
+ <None Include="Content\Fonts\bigfont.xnb">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="Content\Fonts\SegoeUIMono14.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Include="Content\Fonts\smallfont.xnb">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="Content\Graphics\circle.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\Graphics\neutral-ship.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Include="Content\Graphics\pause-screen.xnb">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
+ <None Include="Content\Graphics\polaritydemotitle.xnb">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="neutral-supercruiser.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
+using Microsoft.Xna.Framework.Media;
+using Microsoft.Xna.Framework.Audio;
using SuperPolarity;
#endregion
Screen EntryScreen;
- SpriteFont DebugFont;
+ protected Song TitleSong;
+ protected Song GameSong;
+ protected SoundEffect GameOverSound;
public SuperPolarity()
: base()
ActorManager.SetGame(this);
ScreenManager.SetGame(this);
- EntryScreen = (Screen)new GameScreen(this);
+ EntryScreen = (Screen)new TitleScreen(this);
}
/// <summary>
InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
EntryScreen.Initialize();
- ScreenManager.Push(EntryScreen);
OutlierBounds = 100;
}
/// </summary>
protected override void LoadContent()
{
+
+ MediaPlayer.IsRepeating = true;
+ GameSong = Content.Load<Song>("Sound\\polaritytheme.wav");
+ GameOverSound = Content.Load<SoundEffect>("Sound\\gameover");
+
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
- EntryScreen.LoadContent();
+ ScreenManager.Push(EntryScreen);
- Player = new Player();
- DebugFont = Content.Load<SpriteFont>("Fonts\\SegoeUIMono14");
+ Player = new Player(this);
}
/// <summary>
ScreenManager.Update(gameTime);
+ Player.Update();
+
base.Update(gameTime);
}
ScreenManager.Draw(spriteBatch);
- spriteBatch.DrawString(DebugFont, "Score: " + Player.Score.ToString(), new Vector2(10, 10), Color.LightGray);
- spriteBatch.DrawString(DebugFont, "Multiplier: " + Player.Multiplier.ToString(), new Vector2(10, 30), Color.LightGray);
- spriteBatch.DrawString(DebugFont, "Lives: " + Player.Lives.ToString(), new Vector2(10, 50), Color.LightGray);
-
spriteBatch.End();
base.Draw(gameTime);
}
+
+ public void PlaySong(string songName)
+ {
+ // temp stuff before media manager is in
+ if (songName == "game")
+ {
+ MediaPlayer.Play(GameSong);
+ }
+ }
+
+ public void GameOver()
+ {
+ MediaPlayer.Stop();
+ GameOverSound.Play();
+ ScreenManager.Pop();
+ }
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
namespace SuperPolarity
{
class TitleScreen : Screen
{
+ protected Texture2D TitleImage;
+
public TitleScreen(SuperPolarity newGame) : base(newGame) {}
+
+ public override void LoadContent()
+ {
+ base.LoadContent();
+ TitleImage = Game.Content.Load<Texture2D>("Graphics\\polaritydemotitle");
+ InputController.Bind("pause", HandleStart);
+ }
+
+ public void HandleStart(float value)
+ {
+ if (!Active) { return; }
+ Game.Player.Reset();
+ var gameScreen = new GameScreen(Game);
+ gameScreen.Initialize();
+ ScreenManager.Push(gameScreen);
+ }
+
+ public override void CleanUp()
+ {
+ base.CleanUp();
+ TitleImage = null;
+ }
+
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ base.Draw(spriteBatch);
+ spriteBatch.Draw(TitleImage, new Vector2(0, 0), Color.White);
+ }
+
+ public override void Update(GameTime gameTime)
+ {
+ base.Update(gameTime);
+ InputController.UpdateInput(false);
+ }
}
}
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\square.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Fonts\SegoeUIMono14.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\neutral-supercruiser.xnb
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\polaritytheme.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\bullet.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\polaritychange.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\pause-screen.xnb
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\polaritydemotitle.xnb
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\gameover.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\bomb.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\hit.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Sound\life.wav
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Fonts\bigfont.xnb
+C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Fonts\smallfont.xnb