Skip to content

Commit

Permalink
Version 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceJZ committed Aug 10, 2018
1 parent 682eb6c commit 0a149a5
Show file tree
Hide file tree
Showing 32 changed files with 97 additions and 114 deletions.
2 changes: 1 addition & 1 deletion CFNGamejam2/CFNGamejam2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<Compile Include="Engine\Numbers.cs" />
<Compile Include="Engine\Plane.cs" />
<Compile Include="Engine\PositionedObject.cs" />
<Compile Include="Engine\Services.cs" />
<Compile Include="Engine\Core.cs" />
<Compile Include="Engine\SModel.cs" />
<Compile Include="Engine\Smoke.cs" />
<Compile Include="Engine\SmokeParticle.cs" />
Expand Down
Binary file removed CFNGamejam2/Content/Sounds/BombExplode-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/DropBomb-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/Duck-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/GateExplode-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/MissileFire-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/MissileHit-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/TankIdle-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/TankMove-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/TankShot-old1.wav
Binary file not shown.
Binary file removed CFNGamejam2/Content/Sounds/TankShotHit-old1.wav
Binary file not shown.
25 changes: 6 additions & 19 deletions CFNGamejam2/Engine/AModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public AModel(Game game, XnaModel model, Texture2D texture) : base(game)
public override void Initialize()
{
Enabled = true;
Services.AddDrawableComponent(this);
Core.AddDrawableComponent(this);

Services.GraphicsDM.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
Services.GraphicsDM.GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;
Services.GraphicsDM.GraphicsDevice.BlendState = BlendState.Opaque;
Services.GraphicsDM.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Core.GraphicsDM.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
Core.GraphicsDM.GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;
Core.GraphicsDM.GraphicsDevice.BlendState = BlendState.Opaque;
Core.GraphicsDM.GraphicsDevice.DepthStencilState = DepthStencilState.Default;

BaseWorld = Matrix.Identity;

Expand Down Expand Up @@ -79,19 +79,6 @@ this point to position it in orbit.
Translate - move the moon to the final location, which will be the same
as the location of earth in this case since it's already setup to be in orbit.*/

//Calculate the base transformation by combining
//translation, rotation, and scaling
//BaseWorld = Matrix.CreateScale(ModelScale)
// * Matrix.CreateFromYawPitchRoll(Rotation.Y, Rotation.X, Rotation.Z)
// * Matrix.CreateTranslation(Position);

//if (Child)
//{
// BaseWorld *= Matrix.CreateFromYawPitchRoll(ParentPO.Rotation.Y + ParentPO.ParentRotation.Y,
// ParentPO.Rotation.X + ParentPO.ParentRotation.X,
// ParentPO.Rotation.Z + ParentPO.ParentRotation.Z)
// * Matrix.CreateTranslation(ParentPO.Position + ParentPO.ParentPosition);
//}

MatrixUpdate();

Expand Down Expand Up @@ -129,7 +116,7 @@ public virtual void Draw()
//if (XNATexture != null)
//effect.Texture = XNATexture;// ?? effect.Texture; //Replace texture if XNATexture is not null.

Services.Camera.Draw(effect);
Core.DefaultCamera.Draw(effect);
}

mesh.Draw();
Expand Down
2 changes: 1 addition & 1 deletion CFNGamejam2/Engine/AnimatedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void Draw()
effect.EnableDefaultLighting();
effect.PreferPerPixelLighting = true;
effect.World = localWorld;
Services.Camera.Draw(effect);
Core.DefaultCamera.Draw(effect);
}

mesh.Draw();
Expand Down
2 changes: 1 addition & 1 deletion CFNGamejam2/Engine/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Initialize()
{
base.Initialize();
cameraRotation = Matrix.Identity;
Services.AddUpdateableComponent(this);
Core.AddUpdateableComponent(this);
}

/// <summary>
Expand Down
14 changes: 7 additions & 7 deletions CFNGamejam2/Engine/Services.cs → CFNGamejam2/Engine/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

namespace Engine
{
public sealed class Services : DrawableGameComponent
public sealed class Core : DrawableGameComponent
{
#region Fields
private static Services m_Instance = null;
private static Core m_Instance = null;
private static Random m_RandomNumber;
private static SpriteBatch m_SpriteBatch;
private static GraphicsDeviceManager m_GraphicsDM;
Expand All @@ -35,7 +35,7 @@ public sealed class Services : DrawableGameComponent
/// Instead of using the mInstance this will do the check to see if the Instance is valid
/// where ever you use it. It is also private so it will only get used inside the engine services.
/// </summary>
private static Services Instance
private static Core Instance
{
get
{
Expand All @@ -49,10 +49,10 @@ private static Services Instance
}
}

public static Game TheGame { set => m_Game = value; }
public static Game GameRef { set => m_Game = value; }
public static GraphicsDeviceManager GraphicsDM { get => m_GraphicsDM; }
public static SpriteBatch SpriteBatch { get => m_SpriteBatch; set => m_SpriteBatch = value; }
public static Camera Camera { get => m_Camera; }
public static Camera DefaultCamera { get => m_Camera; }
public static Random RandomNumber { get => m_RandomNumber; }
/// <summary>
/// Returns the window size in pixels, of the height.
Expand Down Expand Up @@ -81,7 +81,7 @@ public static Vector2 WindowSize
/// This is the constructor for the Services
/// You will note that it is private that means that only the Services can only create itself.
/// </summary>
private Services(Game game) : base(game)
private Core(Game game) : base(game)
{
game.Components.Add(this);
// Create a new SpriteBatch, which can be used to draw textures.
Expand Down Expand Up @@ -161,7 +161,7 @@ public static void Initialize(GraphicsDeviceManager graphics, Game game, Vector3
{
m_GraphicsDM = graphics;
//Create the Engine Services
m_Instance = new Services(game);
m_Instance = new Core(game);
m_RandomNumber = new Random(DateTime.Now.Millisecond);
m_Camera = new Camera(game, cameraPosition, Vector3.Zero, Vector3.Zero, othrographic, near, far);
m_Drawable = new List<IDrawComponent>();
Expand Down
8 changes: 4 additions & 4 deletions CFNGamejam2/Engine/Explode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override void Initialize()

public void LoadContent()
{
Cube = Services.LoadModel("Core/Cube");
Cube = Core.LoadModel("Core/Cube");
}

public void BeginRun()
Expand Down Expand Up @@ -65,7 +65,7 @@ public override void Update(GameTime gameTime)
public void Spawn(Vector3 position, float radius, int minCount)
{
Enabled = true;
int count = Services.RandomMinMax(minCount, (int)(minCount + radius * 2));
int count = Core.RandomMinMax(minCount, (int)(minCount + radius * 2));

if (count > Particles.Count)
{
Expand All @@ -81,8 +81,8 @@ public void Spawn(Vector3 position, float radius, int minCount)

foreach (ExplodeParticle particle in Particles)
{
position += new Vector3(Services.RandomMinMax(-radius, radius),
Services.RandomMinMax(-radius, radius), 0);
position += new Vector3(Core.RandomMinMax(-radius, radius),
Core.RandomMinMax(-radius, radius), 0);

particle.Spawn(position);
}
Expand Down
4 changes: 2 additions & 2 deletions CFNGamejam2/Engine/ExplodeParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public override void Spawn(Vector3 position)
base.Spawn(position);

Velocity = RandomVelocity(100);
ModelScale = new Vector3(Services.RandomMinMax(0.5f, 1.5f));
LifeTimer.Reset(Services.RandomMinMax(0.1f, 1));
ModelScale = new Vector3(Core.RandomMinMax(0.5f, 1.5f));
LifeTimer.Reset(Core.RandomMinMax(0.1f, 1));
}
}
}
14 changes: 7 additions & 7 deletions CFNGamejam2/Engine/Plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public override void Initialize()
{
base.Initialize();

PlaneBasicEffect = new BasicEffect(Engine.Services.GraphicsDM.GraphicsDevice);
Engine.Services.AddDrawableComponent(this);
PlaneBasicEffect = new BasicEffect(Engine.Core.GraphicsDM.GraphicsDevice);
Engine.Core.AddDrawableComponent(this);
}

public override void BeginRun()
Expand All @@ -52,9 +52,9 @@ public override void Update(GameTime gameTime)

// Set object and camera info
PlaneBasicEffect.World = BaseWorld;
PlaneBasicEffect.View = Engine.Services.Camera.View;
PlaneBasicEffect.Projection = Engine.Services.Camera.Projection;
Engine.Services.GraphicsDM.GraphicsDevice.SetVertexBuffer(PlaneVertexBuffer);
PlaneBasicEffect.View = Engine.Core.DefaultCamera.View;
PlaneBasicEffect.Projection = Engine.Core.DefaultCamera.Projection;
Engine.Core.GraphicsDM.GraphicsDevice.SetVertexBuffer(PlaneVertexBuffer);
}

public void Draw()
Expand All @@ -63,13 +63,13 @@ public void Draw()
foreach (EffectPass pass in PlaneBasicEffect.CurrentTechnique.Passes)
{
pass.Apply();
Engine.Services.GraphicsDM.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, Verts, 0, 2);
Engine.Core.GraphicsDM.GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, Verts, 0, 2);
}
}

public void Create(Texture2D texture)
{
PlaneVertexBuffer = new VertexBuffer(Engine.Services.GraphicsDM.GraphicsDevice, typeof(VertexPositionTexture),
PlaneVertexBuffer = new VertexBuffer(Engine.Core.GraphicsDM.GraphicsDevice, typeof(VertexPositionTexture),
Verts.Length, BufferUsage.None);

ChangePlaneTexture(texture);
Expand Down
22 changes: 11 additions & 11 deletions CFNGamejam2/Engine/PositionedObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,19 +332,19 @@ public float AngleFromVectorsZ(Vector3 target)

public float RandomRadian()
{
return Services.RandomMinMax(0, MathHelper.TwoPi);
return Core.RandomMinMax(0, MathHelper.TwoPi);
}

public Vector3 RandomVelocity(float speed)
{
float ang = RandomRadian();
float amt = Services.RandomMinMax(speed * 0.15f, speed);
float amt = Core.RandomMinMax(speed * 0.15f, speed);
return VelocityFromAngleZ(ang, amt);
}

public Vector3 RandomVelocity(float speed, float radianDirection)
{
float amt = Services.RandomMinMax(speed * 0.15f, speed);
float amt = Core.RandomMinMax(speed * 0.15f, speed);
return VelocityFromAngleZ(radianDirection, amt);
}
/// <summary>
Expand Down Expand Up @@ -408,8 +408,8 @@ public Vector3 VelocityFromAngleZ(float magnitude)

public Vector2 RandomEdge()
{
return new Vector2(Services.WindowWidth * 0.5f,
Services.RandomMinMax(-Services.WindowHeight * 0.45f, Services.WindowHeight * 0.45f));
return new Vector2(Core.WindowWidth * 0.5f,
Core.RandomMinMax(-Core.WindowHeight * 0.45f, Core.WindowHeight * 0.45f));
}
/// <summary>
/// Aims at target using the Y ground Plane.
Expand Down Expand Up @@ -516,26 +516,26 @@ public float AimAtTargetZ(Vector3 target, float facingAngle, float magnitude)

public void CheckWindowBorders()
{
if (Position.X > Services.WindowWidth)
if (Position.X > Core.WindowWidth)
Position.X = 0;

if (Position.X < 0)
Position.X = Services.WindowWidth;
Position.X = Core.WindowWidth;

if (Position.Y > Services.WindowHeight)
if (Position.Y > Core.WindowHeight)
Position.Y = 0;

if (Position.Y < 0)
Position.Y = Services.WindowHeight;
Position.Y = Core.WindowHeight;
}

public void CheckWindowSideBorders(int width)
{
if (Position.X + width > Services.WindowWidth)
if (Position.X + width > Core.WindowWidth)
Position.X = 0;

if (Position.X < 0)
Position.X = Services.WindowWidth - width;
Position.X = Core.WindowWidth - width;
}

#endregion
Expand Down
12 changes: 6 additions & 6 deletions CFNGamejam2/Engine/SModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SModel(Game game) : base(game)
public override void Initialize()
{
base.Initialize();
Services.AddDrawableComponent(this);
Core.AddDrawableComponent(this);

}

Expand Down Expand Up @@ -66,14 +66,14 @@ public void Draw()
{
effect.LightingEnabled = true; // Turn on the lighting subsystem.
effect.PreferPerPixelLighting = true;
effect.DirectionalLight0.DiffuseColor = Services.DefuseLight;
effect.DirectionalLight0.Direction = Services.LightDirection;
effect.DirectionalLight0.SpecularColor = Services.SpecularColor;
effect.AmbientLightColor = Services.AmbientLightColor;
effect.DirectionalLight0.DiffuseColor = Core.DefuseLight;
effect.DirectionalLight0.Direction = Core.LightDirection;
effect.DirectionalLight0.SpecularColor = Core.SpecularColor;
effect.AmbientLightColor = Core.AmbientLightColor;

effect.World = localWorld;

Services.Camera.Draw(effect);
Core.DefaultCamera.Draw(effect);
}

mesh.Draw();
Expand Down
8 changes: 4 additions & 4 deletions CFNGamejam2/Engine/Smoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Initialize()

public void LoadContent()
{
Cube = Services.LoadModel("Core/Cube");
Cube = Core.LoadModel("Core/Cube");
}

public void BeginRun()
Expand All @@ -62,7 +62,7 @@ public void Spawn(Vector3 position, float radius, int minCount)
Enabled = true;
Position = position;
Radius = radius;
int count = Services.RandomMinMax(minCount, (int)(minCount + radius * 10));
int count = Core.RandomMinMax(minCount, (int)(minCount + radius * 10));

if (count > Particles.Count)
{
Expand Down Expand Up @@ -94,8 +94,8 @@ public void Kill()
void SpawnParticle(SmokeParticle particle)
{
Vector3 position = Position;
position += new Vector3(Services.RandomMinMax(-Radius, Radius),
Services.RandomMinMax(-Radius, Radius), 0);
position += new Vector3(Core.RandomMinMax(-Radius, Radius),
Core.RandomMinMax(-Radius, Radius), 0);
particle.Spawn(position);
}
}
Expand Down
10 changes: 5 additions & 5 deletions CFNGamejam2/Engine/SmokeParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public override void Spawn(Vector3 position)
{
base.Spawn(position);

Scale = Services.RandomMinMax(1, 2);
LifeTimer.Reset(Services.RandomMinMax(3.1f, 15.5f));
Velocity.Y = Services.RandomMinMax(1.1f, 4.5f);
Scale = Core.RandomMinMax(1, 2);
LifeTimer.Reset(Core.RandomMinMax(3.1f, 15.5f));
Velocity.Y = Core.RandomMinMax(1.1f, 4.5f);
float drift = 1.5f;
Velocity.X = Services.RandomMinMax(-drift, drift);
Velocity.Z = Services.RandomMinMax(-drift, drift);
Velocity.X = Core.RandomMinMax(-drift, drift);
Velocity.Z = Core.RandomMinMax(-drift, drift);
}
}
}
6 changes: 3 additions & 3 deletions CFNGamejam2/Engine/Sprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void Initialize()
{
base.Initialize();

Services.AddDrawableComponent(this);
Core.AddDrawableComponent(this);
m_FrameTime.Amount = 0.1f;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ public void Draw()
{
if (m_Frames.Count > 0)
{
Services.SpriteBatch.Draw(m_Texture, Position, Source, m_TintColor, RotationInRadians,
Core.SpriteBatch.Draw(m_Texture, Position, Source, m_TintColor, RotationInRadians,
Vector2.Zero, Scale, SpriteEffects.None, 0.0f);
}
}
Expand All @@ -237,7 +237,7 @@ public void Draw()
{
if (child.Active && child.Visable)
{
Services.SpriteBatch.Draw(child.Texture, child.Position, child.Source, m_TintColor, child.RotationInRadians,
Core.SpriteBatch.Draw(child.Texture, child.Position, child.Source, m_TintColor, child.RotationInRadians,
Vector2.Zero, child.Scale, SpriteEffects.None, 0.0f);
}
}
Expand Down
4 changes: 2 additions & 2 deletions CFNGamejam2/Engine/SpriteFontDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Initialize()
{
base.Initialize();

Services.AddDrawableComponent(this);
Core.AddDrawableComponent(this);
}

public virtual void LoadContent()
Expand Down Expand Up @@ -58,7 +58,7 @@ public void Draw()
{
if (Active)
{
Services.SpriteBatch.DrawString(m_SpriteFont, m_String, Position, m_TintColor);
Core.SpriteBatch.DrawString(m_SpriteFont, m_String, Position, m_TintColor);
}
}
}
Expand Down
Loading

0 comments on commit 0a149a5

Please sign in to comment.