aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2013-11-18 21:51:56 -0600
committerBen Beltran <ben@nsovocal.com>2013-11-18 21:51:56 -0600
commit74c155708d85abfc2cf227c08de4f27003015b3f (patch)
tree2e7f6fdad12ae6509832b0e5ee497af7ed72e5e2
parent38c7d3f9eb7d63937c6654ff5dd6046ce02dd59c (diff)
I have the worst commits ever.
-rw-r--r--Super Polarity Content/Super Polarity ContentContent/Fonts/SegoeUIMono14.spritefont60
-rw-r--r--Super Polarity/ActorFactory.cs4
-rw-r--r--Super Polarity/ActorManager.cs25
-rw-r--r--Super Polarity/Actors/Actor.cs66
-rw-r--r--Super Polarity/Actors/Bullet.cs27
-rw-r--r--Super Polarity/Actors/MainShip.cs69
-rw-r--r--Super Polarity/Actors/Ship.cs5
-rw-r--r--Super Polarity/Actors/StandardShip.cs33
-rw-r--r--Super Polarity/Content/Fonts/SegoeUIMono14.xnbbin0 -> 20142 bytes
-rw-r--r--Super Polarity/GameScreen.cs44
-rw-r--r--Super Polarity/MenuItem.cs11
-rw-r--r--Super Polarity/MenuWidget.cs11
-rw-r--r--Super Polarity/Player.cs46
-rw-r--r--Super Polarity/ScoreScreen.cs16
-rw-r--r--Super Polarity/Screen.cs38
-rw-r--r--Super Polarity/ScreenManager.cs48
-rw-r--r--Super Polarity/Super Polarity.csproj12
-rw-r--r--Super Polarity/SuperPolarity.cs53
-rw-r--r--Super Polarity/TitleScreen.cs12
-rw-r--r--Super Polarity/Widget.cs58
-rw-r--r--Super Polarity/bin/WindowsGL/Debug/Super Polarity.exebin55808 -> 60928 bytes
-rw-r--r--Super Polarity/bin/WindowsGL/Debug/Super Polarity.pdbbin81408 -> 112128 bytes
-rw-r--r--Super Polarity/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cachebin8265 -> 8384 bytes
-rw-r--r--Super Polarity/obj/x86/Debug/Super Polarity.csproj.FileListAbsolute.txt1
-rw-r--r--Super Polarity/obj/x86/Debug/Super Polarity.exebin55808 -> 60928 bytes
-rw-r--r--Super Polarity/obj/x86/Debug/Super Polarity.pdbbin81408 -> 112128 bytes
26 files changed, 604 insertions, 35 deletions
diff --git a/Super Polarity Content/Super Polarity ContentContent/Fonts/SegoeUIMono14.spritefont b/Super Polarity Content/Super Polarity ContentContent/Fonts/SegoeUIMono14.spritefont
new file mode 100644
index 0000000..6c68f5d
--- /dev/null
+++ b/Super Polarity Content/Super Polarity ContentContent/Fonts/SegoeUIMono14.spritefont
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+This file contains an xml description of a font, and will be read by the XNA
+Framework Content Pipeline. Follow the comments to customize the appearance
+of the font in your game, and to change the characters which are available to draw
+with.
+-->
+<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
+ <Asset Type="Graphics:FontDescription">
+
+ <!--
+ Modify this string to change the font that will be imported.
+ -->
+ <FontName>Segoe UI Mono</FontName>
+
+ <!--
+ Size is a float value, measured in points. Modify this value to change
+ the size of the font.
+ -->
+ <Size>14</Size>
+
+ <!--
+ Spacing is a float value, measured in pixels. Modify this value to change
+ the amount of spacing in between characters.
+ -->
+ <Spacing>0</Spacing>
+
+ <!--
+ UseKerning controls the layout of the font. If this value is true, kerning information
+ will be used when placing characters.
+ -->
+ <UseKerning>true</UseKerning>
+
+ <!--
+ Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
+ and "Bold, Italic", and are case sensitive.
+ -->
+ <Style>Regular</Style>
+
+ <!--
+ If you uncomment this line, the default character will be substituted if you draw
+ or measure text that contains characters which were not included in the font.
+ -->
+ <!-- <DefaultCharacter>*</DefaultCharacter> -->
+
+ <!--
+ CharacterRegions control what letters are available in the font. Every
+ character from Start to End will be built and made available for drawing. The
+ default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
+ character set. The characters are ordered according to the Unicode standard.
+ See the documentation for more information.
+ -->
+ <CharacterRegions>
+ <CharacterRegion>
+ <Start>&#32;</Start>
+ <End>&#126;</End>
+ </CharacterRegion>
+ </CharacterRegions>
+ </Asset>
+</XnaContent>
diff --git a/Super Polarity/ActorFactory.cs b/Super Polarity/ActorFactory.cs
index 4ebbb4c..3a2dbab 100644
--- a/Super Polarity/ActorFactory.cs
+++ b/Super Polarity/ActorFactory.cs
@@ -10,7 +10,7 @@ namespace SuperPolarity
{
static class ActorFactory
{
- static internal Game Game;
+ static internal SuperPolarity Game;
static public MainShip CreateMainShip(Vector2 position)
{
@@ -48,7 +48,7 @@ namespace SuperPolarity
return ship;
}
- internal static void SetGame(Game game)
+ internal static void SetGame(SuperPolarity game)
{
ActorFactory.Game = game;
}
diff --git a/Super Polarity/ActorManager.cs b/Super Polarity/ActorManager.cs
index 1b4ef96..8cd265a 100644
--- a/Super Polarity/ActorManager.cs
+++ b/Super Polarity/ActorManager.cs
@@ -10,9 +10,9 @@ namespace SuperPolarity
static class ActorManager
{
- static Game Game;
+ static SuperPolarity Game;
static int OutlierBounds;
- static List<Actor> Actors;
+ static IList<Actor> Actors;
static ActorManager()
{
@@ -50,12 +50,16 @@ namespace SuperPolarity
static void CheckActors()
{
- var i = 0;
- foreach (Actor actor in Actors)
+ for (var i = Actors.Count - 1; i >= 0; i--)
{
- i++;
- foreach (Actor other in Actors.Skip(i))
+ if (i >= Actors.Count) {
+ i = Actors.Count - 1;
+ }
+ Actor actor = Actors[i];
+ for (var j = i - 1; j >= 0; j--)
{
+ Actor other = Actors[j];
+
CheckCollision(actor, other);
if (actor.GetType().IsSubclassOf(typeof(Ship)) && other.GetType().IsSubclassOf(typeof(Ship)))
@@ -68,6 +72,13 @@ namespace SuperPolarity
static void CheckCollision(Actor actor, Actor other)
{
+ var collision = Rectangle.Intersect(actor.Box, other.Box);
+ var inverseCollision = Rectangle.Intersect(other.Box, actor.Box);
+ if (!collision.IsEmpty && !actor.Dying && !other.Dying)
+ {
+ actor.Collide(other, collision);
+ other.Collide(actor, inverseCollision);
+ }
}
@@ -103,7 +114,7 @@ namespace SuperPolarity
}
}
- internal static void SetGame(Game game)
+ internal static void SetGame(SuperPolarity game)
{
Game = game;
}
diff --git a/Super Polarity/Actors/Actor.cs b/Super Polarity/Actors/Actor.cs
index 588ff14..8c71af0 100644
--- a/Super Polarity/Actors/Actor.cs
+++ b/Super Polarity/Actors/Actor.cs
@@ -10,7 +10,7 @@ namespace SuperPolarity
{
class Actor
{
- protected Game game;
+ protected SuperPolarity game;
public List<Actor> Children;
@@ -18,6 +18,9 @@ namespace SuperPolarity
protected Texture2D Texture;
protected Vector2 Origin;
public bool Active;
+ public Rectangle Box;
+ protected Vector4 BoxDimensions;
+ protected Texture2D BoxTexture;
// Physical Properties
public Vector2 Position;
@@ -28,6 +31,13 @@ namespace SuperPolarity
// Constraints / Behavior
protected float MaxVelocity;
protected float AccelerationRate;
+ protected int HP;
+ protected bool Immortal;
+ public bool Dying;
+ public int Value;
+ protected Color Color;
+
+ public Actor Parent;
public int Width
{
@@ -39,7 +49,7 @@ namespace SuperPolarity
get { return Texture.Height; }
}
- public Actor(Game newGame)
+ public Actor(SuperPolarity newGame)
{
game = newGame;
}
@@ -58,6 +68,27 @@ namespace SuperPolarity
MaxVelocity = 5;
AccelerationRate = 10;
+
+ HP = 1;
+ Immortal = false;
+ BoxDimensions.X = 20;
+ BoxDimensions.Y = 20;
+ BoxDimensions.W = 20;
+ BoxDimensions.Z = 20;
+
+ Dying = false;
+ Value = 1;
+
+ InitBox();
+ BoxTexture = new Texture2D(game.GraphicsDevice, 1, 1);
+ BoxTexture.SetData(new Color[] { Color.White });
+
+ Color = Color.White;
+ }
+
+ protected void InitBox()
+ {
+ Box = new Rectangle((int)(Position.X - BoxDimensions.X), (int)(Position.Y - BoxDimensions.X), (int)(BoxDimensions.X + BoxDimensions.W), (int)(BoxDimensions.Y + BoxDimensions.Z));
}
public void AutoDeccelerate(GameTime gameTime)
@@ -120,6 +151,13 @@ namespace SuperPolarity
Move(gameTime);
ChangeAngle();
CheckOutliers();
+ UpdateBox();
+ }
+
+ protected virtual void UpdateBox()
+ {
+ Box.X = (int)(Position.X - BoxDimensions.X);
+ Box.Y = (int)(Position.Y - BoxDimensions.Y);
}
public virtual void Move(GameTime gameTime)
@@ -167,7 +205,8 @@ namespace SuperPolarity
child.Draw(spriteBatch);
}
- spriteBatch.Draw(Texture, Position, null, Color.White, Angle, Origin, 1f, SpriteEffects.None, 0f);
+ spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f);
+ spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25));
}
void CheckOutliers()
@@ -183,5 +222,26 @@ namespace SuperPolarity
}
}
}
+
+ public virtual void Collide(Actor other, Rectangle collision)
+ {
+ }
+
+ public void TakeDamage(int amount)
+ {
+ if (!Immortal)
+ {
+ HP = HP - amount;
+ if (HP < 0)
+ {
+ Die();
+ }
+ }
+ }
+
+ protected virtual void Die()
+ {
+ Dying = true;
+ }
}
}
diff --git a/Super Polarity/Actors/Bullet.cs b/Super Polarity/Actors/Bullet.cs
index 6862e69..5a7be03 100644
--- a/Super Polarity/Actors/Bullet.cs
+++ b/Super Polarity/Actors/Bullet.cs
@@ -10,8 +10,9 @@ namespace SuperPolarity
class Bullet : Actor
{
protected ParticleEngine particleEngine;
+ public int Power;
- public Bullet(Game newGame)
+ public Bullet(SuperPolarity newGame)
: base(newGame)
{
}
@@ -24,6 +25,11 @@ namespace SuperPolarity
public override void Initialize(Texture2D texture, Vector2 position)
{
base.Initialize(texture, position);
+ BoxDimensions.X = 10;
+ BoxDimensions.Y = 10;
+ BoxDimensions.W = 10;
+ BoxDimensions.Z = 10;
+ InitBox();
particleEngine = ParticleEffectFactory.CreateBullet(position);
}
@@ -32,7 +38,10 @@ namespace SuperPolarity
Velocity.X = (float)(MaxVelocity * Math.Cos(Angle));
Velocity.Y = (float)(MaxVelocity * Math.Sin(Angle));
+ Power = 1;
+
Position += Velocity;
+ UpdateBox();
particleEngine.Update();
particleEngine.EmitterLocation = Position;
@@ -43,5 +52,21 @@ namespace SuperPolarity
base.Draw(spriteBatch);
particleEngine.Draw(spriteBatch);
}
+
+ public override void Collide(Actor other, Rectangle collision)
+ {
+ if (Dying) { return; }
+ if (other.GetType().IsAssignableFrom(typeof(StandardShip)))
+ {
+ Die();
+ return;
+ }
+ }
+
+ protected override void Die()
+ {
+ ActorManager.CheckOut(this);
+ Parent.Children.Remove(this);
+ }
}
}
diff --git a/Super Polarity/Actors/MainShip.cs b/Super Polarity/Actors/MainShip.cs
index 1f4f22a..616f16e 100644
--- a/Super Polarity/Actors/MainShip.cs
+++ b/Super Polarity/Actors/MainShip.cs
@@ -20,7 +20,11 @@ namespace SuperPolarity
protected bool Shooting;
protected int ShotCooldown;
- public MainShip(Game newGame) : base(newGame) {}
+ protected float CurrentImmortalTime;
+ protected float MaxImmortalTime;
+ protected bool Flashing;
+
+ public MainShip(SuperPolarity newGame) : base(newGame) {}
~MainShip()
{
@@ -38,6 +42,13 @@ namespace SuperPolarity
SetPolarity(Polarity.Positive);
ShotCooldown = 50;
+ MaxImmortalTime = 1500;
+
+ BoxDimensions.X = 2;
+ BoxDimensions.Y = 2;
+ BoxDimensions.W = 2;
+ BoxDimensions.Z = 2;
+ InitBox();
BindInput();
}
@@ -57,7 +68,11 @@ namespace SuperPolarity
protected void HandleShot(float value)
{
- Children.Add(ActorFactory.CreateBullet(Position, Angle));
+ 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);
@@ -97,6 +112,7 @@ namespace SuperPolarity
{
base.SwitchPolarity();
SwitchParticleEngine(CurrentPolarity);
+ game.Player.ResetMultiplier();
}
public override void SetPolarity(Polarity newPolarity)
@@ -127,9 +143,35 @@ namespace SuperPolarity
particleEngine.EmitterLocation = Position;
particleEngine.Update();
ConstrainToEdges();
+ UpdateImmortality(gameTime);
Shooting = false;
}
+ public void UpdateImmortality(GameTime gameTime)
+ {
+ if (Immortal)
+ {
+ CurrentImmortalTime += gameTime.ElapsedGameTime.Milliseconds;
+
+ if (Flashing)
+ {
+ Color = new Color(255, 255, 255, 128);
+ }
+ else
+ {
+ Color = Color.White;
+ }
+
+ Flashing = !Flashing;
+
+ if (CurrentImmortalTime > MaxImmortalTime)
+ {
+ Immortal = false;
+ Color = Color.White;
+ }
+ }
+ }
+
public override void Move(GameTime gameTime)
{
base.Move(gameTime);
@@ -207,5 +249,28 @@ namespace SuperPolarity
particleEngine.Draw(spriteBatch);
base.Draw(spriteBatch);
}
+
+ public override void Collide(Actor other, Rectangle collision)
+ {
+ if (other.GetType().IsAssignableFrom(typeof(StandardShip)) &&
+ !Immortal)
+ {
+ Die();
+ }
+ }
+
+ protected override void Die()
+ {
+ game.Player.Lives = game.Player.Lives - 1;
+ game.Player.ResetMultiplier();
+ if (game.Player.Lives < 0)
+ {
+ Dying = true;
+ }
+ else {
+ Immortal = true;
+ CurrentImmortalTime = 0;
+ }
+ }
}
}
diff --git a/Super Polarity/Actors/Ship.cs b/Super Polarity/Actors/Ship.cs
index b4706ac..2839c97 100644
--- a/Super Polarity/Actors/Ship.cs
+++ b/Super Polarity/Actors/Ship.cs
@@ -11,7 +11,6 @@ namespace SuperPolarity
{
public enum Polarity : byte { Negative, Positive, Neutral };
- protected uint HP;
public Polarity CurrentPolarity;
public uint MagneticRadius;
@@ -22,10 +21,12 @@ namespace SuperPolarity
protected bool Magnetizing;
- public Ship(Game newGame) : base(newGame) {
+ public Ship(SuperPolarity newGame) : base(newGame) {
MagneticRadius = 250;
RepelRadius = 100;
+ HP = 5;
+
FleeVelocity = 5;
ActVelocity = 2;
ChargeVelocity = 1.5f;
diff --git a/Super Polarity/Actors/StandardShip.cs b/Super Polarity/Actors/StandardShip.cs
index 50a671a..556be0f 100644
--- a/Super Polarity/Actors/StandardShip.cs
+++ b/Super Polarity/Actors/StandardShip.cs
@@ -20,7 +20,7 @@ namespace SuperPolarity
protected Random Random;
protected bool AddingAngle;
- public StandardShip(Game newGame) : base(newGame) {}
+ public StandardShip(SuperPolarity newGame) : base(newGame) {}
public override void Initialize(Texture2D texture, Vector2 position)
{
@@ -37,6 +37,8 @@ namespace SuperPolarity
RotationFactor = (float) (3 * Math.PI / 180);
Random = new Random(BitConverter.ToInt32(cryptoResult, 0));
AddingAngle = true;
+
+ HP = 5;
}
public override void Magnetize(Ship ship, float distance, float angle)
@@ -56,6 +58,7 @@ namespace SuperPolarity
}
ChangeAngle();
Position += Velocity;
+ UpdateBox();
Magnetizing = false;
}
@@ -110,5 +113,33 @@ namespace SuperPolarity
Velocity.Y = -Velocity.Y;
}
}
+
+ public override void Collide(Actor other, Rectangle collision)
+ {
+ if (Dying)
+ {
+ return;
+ }
+
+ if (other.GetType() == typeof(MainShip))
+ {
+ Die();
+ return;
+ }
+
+ if (other.GetType() == typeof(Bullet))
+ {
+ var theBullet = (Bullet)other;
+ TakeDamage(theBullet.Power);
+ }
+ }
+
+ protected override void Die()
+ {
+ ActorManager.CheckOut(this);
+ Renderer.CheckOut(this);
+ game.Player.AddScore(Value);
+ game.Player.AddMultiplier(1);
+ }
}
}
diff --git a/Super Polarity/Content/Fonts/SegoeUIMono14.xnb b/Super Polarity/Content/Fonts/SegoeUIMono14.xnb
new file mode 100644
index 0000000..51c4abd
--- /dev/null
+++ b/Super Polarity/Content/Fonts/SegoeUIMono14.xnb
Binary files differ
diff --git a/Super Polarity/GameScreen.cs b/Super Polarity/GameScreen.cs
new file mode 100644
index 0000000..4404b16
--- /dev/null
+++ b/Super Polarity/GameScreen.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+using Microsoft.Xna.Framework.Input;
+
+namespace SuperPolarity
+{
+ class GameScreen : Screen
+ {
+ public GameScreen(SuperPolarity newGame) : base(newGame) {}
+
+ public override void Initialize()
+ {
+ InputController.RegisterEventForButton("changePolarity", Buttons.A);
+ InputController.RegisterEventForKey("changePolarity", Keys.Z);
+
+ InputController.RegisterEventForButton("shoot", Buttons.X);
+ InputController.RegisterEventForKey("shoot", Keys.X);
+ }
+
+ public override void LoadContent()
+ {
+ 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));
+ Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200)));
+ Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200)));
+ }
+
+ public override void Update(GameTime gameTime)
+ {
+ InputController.UpdateInput();
+ ActorManager.Update(gameTime);
+ }
+
+ public override void Draw(SpriteBatch spriteBatch)
+ {
+ Renderer.Draw(spriteBatch);
+ }
+ }
+}
diff --git a/Super Polarity/MenuItem.cs b/Super Polarity/MenuItem.cs
new file mode 100644
index 0000000..77561a9
--- /dev/null
+++ b/Super Polarity/MenuItem.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ class MenuItem : Widget
+ {
+ }
+}
diff --git a/Super Polarity/MenuWidget.cs b/Super Polarity/MenuWidget.cs
new file mode 100644
index 0000000..8131e50
--- /dev/null
+++ b/Super Polarity/MenuWidget.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ class MenuWidget : Widget
+ {
+ }
+}
diff --git a/Super Polarity/Player.cs b/Super Polarity/Player.cs
new file mode 100644
index 0000000..25e66da
--- /dev/null
+++ b/Super Polarity/Player.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ public class Player
+ {
+ public int Score;
+ public int Multiplier;
+ public int Lives;
+
+ public Player()
+ {
+ Score = 0;
+ Multiplier = 1;
+ Lives = 3;
+ }
+
+ public void AddScore(int value)
+ {
+ Score = Score + (value * Multiplier);
+ }
+
+ public void AddMultiplier(int value)
+ {
+ Multiplier = Multiplier + 1;
+ }
+
+ public void ResetMultiplier()
+ {
+ Multiplier = 1;
+ }
+
+ public void Draw()
+ {
+
+ }
+
+ public void Update()
+ {
+
+ }
+ }
+}
diff --git a/Super Polarity/ScoreScreen.cs b/Super Polarity/ScoreScreen.cs
new file mode 100644
index 0000000..b96ae9b
--- /dev/null
+++ b/Super Polarity/ScoreScreen.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ class ScoreScreen : Screen
+ {
+ public ScoreScreen(SuperPolarity newGame) : base(newGame) {}
+
+ public override void Initialize()
+ {
+ }
+ }
+}
diff --git a/Super Polarity/Screen.cs b/Super Polarity/Screen.cs
new file mode 100644
index 0000000..8cea5c9
--- /dev/null
+++ b/Super Polarity/Screen.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace SuperPolarity
+{
+ class Screen
+ {
+ protected SuperPolarity Game;
+ public Screen(SuperPolarity game)
+ {
+ Game = game;
+ }
+
+ public virtual void Update(GameTime gameTime)
+ {
+ }
+
+ public virtual void Draw(SpriteBatch spriteBatch)
+ {
+ }
+
+ public virtual void LoadContent()
+ {
+ }
+
+ public virtual void Initialize()
+ {
+ }
+
+ public virtual void CleanUp()
+ {
+ }
+ }
+}
diff --git a/Super Polarity/ScreenManager.cs b/Super Polarity/ScreenManager.cs
new file mode 100644
index 0000000..04c10a4
--- /dev/null
+++ b/Super Polarity/ScreenManager.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace SuperPolarity
+{
+ static class ScreenManager
+ {
+ static Stack<Screen> Screens;
+ static SuperPolarity Game;
+
+ static ScreenManager()
+ {
+ Screens = new Stack<Screen>();
+ }
+
+ static public void Push(Screen screen)
+ {
+ Screens.Push(screen);
+ }
+
+ static public void Pop()
+ {
+ Screens.Pop();
+ }
+
+ static public void Update(GameTime gameTime)
+ {
+ Screens.Peek().Update(gameTime);
+ }
+
+ static public void Draw(SpriteBatch spriteBatch)
+ {
+ foreach (Screen screen in Screens)
+ {
+ screen.Draw(spriteBatch);
+ }
+ }
+
+ internal static void SetGame(SuperPolarity game)
+ {
+ Game = game;
+ }
+ }
+}
diff --git a/Super Polarity/Super Polarity.csproj b/Super Polarity/Super Polarity.csproj
index 193edde..2cd1d08 100644
--- a/Super Polarity/Super Polarity.csproj
+++ b/Super Polarity/Super Polarity.csproj
@@ -39,17 +39,26 @@
<Compile Include="ActorManager.cs" />
<Compile Include="Actors\StandardShip.cs" />
<Compile Include="Actors\Bullet.cs" />
+ <Compile Include="GameScreen.cs" />
<Compile Include="InputController.cs" />
<Compile Include="Actors\MainShip.cs" />
+ <Compile Include="MenuItem.cs" />
+ <Compile Include="MenuWidget.cs" />
<Compile Include="Particle.cs" />
<Compile Include="ParticleEffectFactory.cs" />
<Compile Include="ParticleEngine.cs" />
<Compile Include="Actors\Actor.cs" />
<Compile Include="Actors\Ship.cs" />
+ <Compile Include="Player.cs" />
<Compile Include="Renderer.cs" />
+ <Compile Include="ScoreScreen.cs" />
+ <Compile Include="Screen.cs" />
+ <Compile Include="ScreenManager.cs" />
<Compile Include="SuperPolarity.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TitleScreen.cs" />
+ <Compile Include="Widget.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="OpenTK">
@@ -78,6 +87,9 @@
<Folder Include="Content\Sound\" />
</ItemGroup>
<ItemGroup>
+ <None Include="Content\Fonts\SegoeUIMono14.xnb">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="Content\Graphics\circle.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
diff --git a/Super Polarity/SuperPolarity.cs b/Super Polarity/SuperPolarity.cs
index 21d1ed4..6689167 100644
--- a/Super Polarity/SuperPolarity.cs
+++ b/Super Polarity/SuperPolarity.cs
@@ -17,20 +17,33 @@ namespace SuperPolarity
/// </summary>
public class SuperPolarity : Game
{
- public static GraphicsDeviceManager graphics;
+ public GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public static int OutlierBounds;
+ public Player Player;
+
+ Screen EntryScreen;
+
+ SpriteFont DebugFont;
+
public SuperPolarity()
: base()
{
- SuperPolarity.graphics = new GraphicsDeviceManager(this);
- SuperPolarity.graphics.PreferMultiSampling = true;
+ graphics = new GraphicsDeviceManager(this);
+ graphics.PreferMultiSampling = true;
+ graphics.PreferredBackBufferWidth = 1280;
+ graphics.PreferredBackBufferHeight = 720;
+ graphics.ToggleFullScreen();
+
Content.RootDirectory = "Content";
ActorFactory.SetGame(this);
ParticleEffectFactory.SetGame(this);
ActorManager.SetGame(this);
+ ScreenManager.SetGame(this);
+
+ EntryScreen = (Screen)new GameScreen(this);
}
/// <summary>
@@ -43,13 +56,19 @@ namespace SuperPolarity
{
base.Initialize();
- OutlierBounds = 100;
+ InputController.RegisterEventForKey("fullScreenToggle", Keys.F11);
+ InputController.Bind("fullScreenToggle", HandleFullScreenToggle);
- InputController.RegisterEventForButton("changePolarity", Buttons.A);
- InputController.RegisterEventForKey("changePolarity", Keys.Z);
+ EntryScreen.Initialize();
+ ScreenManager.Push(EntryScreen);
- InputController.RegisterEventForButton("shoot", Buttons.X);
- InputController.RegisterEventForKey("shoot", Keys.X);
+ OutlierBounds = 100;
+ }
+
+ protected void HandleFullScreenToggle(float value)
+ {
+ graphics.ToggleFullScreen();
+ graphics.ApplyChanges();
}
/// <summary>
@@ -61,11 +80,10 @@ namespace SuperPolarity
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
- Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
+ EntryScreen.LoadContent();
- Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
- Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200)));
- Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200)));
+ Player = new Player();
+ DebugFont = Content.Load<SpriteFont>("Fonts\\SegoeUIMono14");
}
/// <summary>
@@ -87,10 +105,7 @@ namespace SuperPolarity
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
- // TODO: Add your update logic here
-
- InputController.UpdateInput();
- ActorManager.Update(gameTime);
+ ScreenManager.Update(gameTime);
base.Update(gameTime);
}
@@ -105,7 +120,11 @@ namespace SuperPolarity
spriteBatch.Begin();
- Renderer.Draw(spriteBatch);
+ 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();
diff --git a/Super Polarity/TitleScreen.cs b/Super Polarity/TitleScreen.cs
new file mode 100644
index 0000000..5b33218
--- /dev/null
+++ b/Super Polarity/TitleScreen.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ class TitleScreen : Screen
+ {
+ public TitleScreen(SuperPolarity newGame) : base(newGame) {}
+ }
+}
diff --git a/Super Polarity/Widget.cs b/Super Polarity/Widget.cs
new file mode 100644
index 0000000..65c3fd2
--- /dev/null
+++ b/Super Polarity/Widget.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SuperPolarity
+{
+ class Widget
+ {
+ public IList<Widget> Children;
+ public Dictionary<string, List<Action<float>>> Listeners;
+
+ public virtual void AppendChild(Widget widget)
+ {
+ Children.Add(widget);
+ }
+
+ public virtual void Bind(string eventName, Action<float> eventListener)
+ {
+ List<Action<float>> newListenerList;
+ List<Action<float>> listenerList;
+ bool foundListeners;
+
+ if (!Listeners.ContainsKey(eventName))
+ {
+ newListenerList = new List<Action<float>>();
+ Listeners.Add(eventName, newListenerList);
+ }
+
+ foundListeners = Listeners.TryGetValue(eventName, out listenerList);
+
+ listenerList.Add(eventListener);
+ }
+
+ public virtual void Unbind(string eventName, Action<float> eventListener)
+ {
+ // NOT YET IMPLEMENTED;
+ }
+
+ public virtual void Dispatch(string eventName, float value)
+ {
+ List<Action<float>> listenerList;
+ bool foundListeners;
+
+ foundListeners = Listeners.TryGetValue(eventName, out listenerList);
+
+ if (!foundListeners)
+ {
+ return;
+ }
+
+ foreach (Action<float> method in listenerList)
+ {
+ method(value);
+ }
+ }
+ }
+}
diff --git a/Super Polarity/bin/WindowsGL/Debug/Super Polarity.exe b/Super Polarity/bin/WindowsGL/Debug/Super Polarity.exe
index 906274f..0612174 100644
--- a/Super Polarity/bin/WindowsGL/Debug/Super Polarity.exe
+++ b/Super Polarity/bin/WindowsGL/Debug/Super Polarity.exe
Binary files differ
diff --git a/Super Polarity/bin/WindowsGL/Debug/Super Polarity.pdb b/Super Polarity/bin/WindowsGL/Debug/Super Polarity.pdb
index 837ce9b..670745d 100644
--- a/Super Polarity/bin/WindowsGL/Debug/Super Polarity.pdb
+++ b/Super Polarity/bin/WindowsGL/Debug/Super Polarity.pdb
Binary files differ
diff --git a/Super Polarity/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Super Polarity/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index c87641f..c7e2aaa 100644
--- a/Super Polarity/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
+++ b/Super Polarity/obj/x86/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary files differ
diff --git a/Super Polarity/obj/x86/Debug/Super Polarity.csproj.FileListAbsolute.txt b/Super Polarity/obj/x86/Debug/Super Polarity.csproj.FileListAbsolute.txt
index aa6ffb3..9c92990 100644
--- a/Super Polarity/obj/x86/Debug/Super Polarity.csproj.FileListAbsolute.txt
+++ b/Super Polarity/obj/x86/Debug/Super Polarity.csproj.FileListAbsolute.txt
@@ -28,3 +28,4 @@ C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarit
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\star.xnb
C:\Users\Miau\documents\visual studio 2010\Projects\Super Polarity\Super Polarity\bin\WindowsGL\Debug\Content\Graphics\negative-ship.xnb
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
diff --git a/Super Polarity/obj/x86/Debug/Super Polarity.exe b/Super Polarity/obj/x86/Debug/Super Polarity.exe
index 906274f..0612174 100644
--- a/Super Polarity/obj/x86/Debug/Super Polarity.exe
+++ b/Super Polarity/obj/x86/Debug/Super Polarity.exe
Binary files differ
diff --git a/Super Polarity/obj/x86/Debug/Super Polarity.pdb b/Super Polarity/obj/x86/Debug/Super Polarity.pdb
index 837ce9b..670745d 100644
--- a/Super Polarity/obj/x86/Debug/Super Polarity.pdb
+++ b/Super Polarity/obj/x86/Debug/Super Polarity.pdb
Binary files differ