Adding extension for rectangleitem to get position in Farseer units ( getSimPosition )

Adding extension for vector2 to convert back and forth between sim and display units
This commit is contained in:
Nathan Adams 2015-01-01 14:36:46 -06:00
parent 67ab74899f
commit b6e6744a88
8 changed files with 72 additions and 14 deletions

View File

@ -43,7 +43,6 @@ Global
{742C938F-997D-4EFD-95D2-BB09CDADCD2E}.Release|Xbox 360.Build.0 = Release|x86 {742C938F-997D-4EFD-95D2-BB09CDADCD2E}.Release|Xbox 360.Build.0 = Release|x86
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Any CPU.ActiveCfg = Debug|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Any CPU.ActiveCfg = Debug|Xbox 360
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Mixed Platforms.ActiveCfg = Debug|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Mixed Platforms.ActiveCfg = Debug|Xbox 360
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Mixed Platforms.Build.0 = Debug|Xbox 360
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Windows Phone.ActiveCfg = Debug|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Windows Phone.ActiveCfg = Debug|Xbox 360
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Windows Phone.Build.0 = Debug|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|Windows Phone.Build.0 = Debug|Xbox 360
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|x86.ActiveCfg = Debug|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Debug|x86.ActiveCfg = Debug|Xbox 360
@ -61,7 +60,6 @@ Global
{B5664516-72B7-4BA3-9F72-25CAA90867D8}.Release|Xbox 360.Build.0 = Release|Xbox 360 {B5664516-72B7-4BA3-9F72-25CAA90867D8}.Release|Xbox 360.Build.0 = Release|Xbox 360
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Windows Phone.Build.0 = Debug|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|Windows Phone.Build.0 = Debug|Windows Phone
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|x86.ActiveCfg = Debug|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Debug|x86.ActiveCfg = Debug|Windows Phone
@ -79,7 +77,6 @@ Global
{C09D9005-76AC-4F1A-9479-2787BB3DB158}.Release|Xbox 360.Build.0 = Release|Windows Phone {C09D9005-76AC-4F1A-9479-2787BB3DB158}.Release|Xbox 360.Build.0 = Release|Windows Phone
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Any CPU.ActiveCfg = Debug|x86 {A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Any CPU.ActiveCfg = Debug|x86
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Mixed Platforms.Build.0 = Debug|x86
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Windows Phone.ActiveCfg = Debug|x86 {A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|Windows Phone.ActiveCfg = Debug|x86
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|x86.ActiveCfg = Debug|x86 {A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|x86.ActiveCfg = Debug|x86
{A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|x86.Build.0 = Debug|x86 {A622337F-9AE6-492A-85D6-01CCE0D7F9B4}.Debug|x86.Build.0 = Debug|x86

View File

@ -174,8 +174,10 @@
<Compile Include="Engine\Extensions\Double.cs" /> <Compile Include="Engine\Extensions\Double.cs" />
<Compile Include="Engine\Extensions\InputState.cs" /> <Compile Include="Engine\Extensions\InputState.cs" />
<Compile Include="Engine\Extensions\MouseState.cs" /> <Compile Include="Engine\Extensions\MouseState.cs" />
<Compile Include="Engine\Extensions\RectangleItemProperties.cs" />
<Compile Include="Engine\Extensions\String.cs" /> <Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" /> <Compile Include="Engine\Extensions\Texture2D.cs" />
<Compile Include="Engine\Extensions\Vector2.cs" />
<Compile Include="Engine\File\AxiosFile.cs" /> <Compile Include="Engine\File\AxiosFile.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" /> <Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" /> <Compile Include="Engine\File\AxiosRegularFile.cs" />

View File

@ -226,8 +226,10 @@
<Compile Include="Engine\Extensions\InputState.cs" /> <Compile Include="Engine\Extensions\InputState.cs" />
<Compile Include="Engine\Extensions\Double.cs" /> <Compile Include="Engine\Extensions\Double.cs" />
<Compile Include="Engine\Extensions\MouseState.cs" /> <Compile Include="Engine\Extensions\MouseState.cs" />
<Compile Include="Engine\Extensions\RectangleItemProperties.cs" />
<Compile Include="Engine\Extensions\String.cs" /> <Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" /> <Compile Include="Engine\Extensions\Texture2D.cs" />
<Compile Include="Engine\Extensions\Vector2.cs" />
<Compile Include="Engine\File\AxiosFile.cs" /> <Compile Include="Engine\File\AxiosFile.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" /> <Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" /> <Compile Include="Engine\File\AxiosRegularFile.cs" />

View File

@ -167,8 +167,10 @@
<Compile Include="Engine\Extensions\Double.cs" /> <Compile Include="Engine\Extensions\Double.cs" />
<Compile Include="Engine\Extensions\InputState.cs" /> <Compile Include="Engine\Extensions\InputState.cs" />
<Compile Include="Engine\Extensions\MouseState.cs" /> <Compile Include="Engine\Extensions\MouseState.cs" />
<Compile Include="Engine\Extensions\RectangleItemProperties.cs" />
<Compile Include="Engine\Extensions\String.cs" /> <Compile Include="Engine\Extensions\String.cs" />
<Compile Include="Engine\Extensions\Texture2D.cs" /> <Compile Include="Engine\Extensions\Texture2D.cs" />
<Compile Include="Engine\Extensions\Vector2.cs" />
<Compile Include="Engine\File\AxiosFile.cs" /> <Compile Include="Engine\File\AxiosFile.cs" />
<Compile Include="Engine\File\AxiosIsolatedFile.cs" /> <Compile Include="Engine\File\AxiosIsolatedFile.cs" />
<Compile Include="Engine\File\AxiosRegularFile.cs" /> <Compile Include="Engine\File\AxiosRegularFile.cs" />

View File

@ -134,6 +134,8 @@
* - Removing cache from Gleed2D as ContentManager automatically does this * - Removing cache from Gleed2D as ContentManager automatically does this
* - Adding cache * - Adding cache
* - Adding XOR Shift random class * - Adding XOR Shift random class
* - Adding extension for rectangleitem to get position in Farseer units ( getSimPosition )
* - Adding extension for vector2 to convert back and forth between sim and display units
* *
*/ */
#endregion #endregion

View File

@ -1,26 +1,27 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq; using System.Linq;
using System.Xml.Linq;
using Axios.Engine.Extensions;
using Axios.Engine.File;
using Axios.Engine.Gleed2D;
using Axios.Engine.Interfaces; using Axios.Engine.Interfaces;
using Axios.Engine.Log; using Axios.Engine.Log;
using Axios.Engine.Structures; using Axios.Engine.Structures;
using Axios.Engine.UI; using Axios.Engine.UI;
using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics;
using FarseerPhysics.Factories;
using FarseerPhysics.SamplesFramework; using FarseerPhysics.SamplesFramework;
using GameStateManagement;
using Gleed2D.Core;
using Gleed2D.InGame;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using GameStateManagement;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using Axios.Engine.Extensions;
using System.IO;
using System.IO.Compression;
using Gleed2D.InGame;
using Axios.Engine.File;
using System.Xml.Linq;
using Gleed2D.Core;
using System.Diagnostics;
using Axios.Engine.Gleed2D;
namespace Axios.Engine namespace Axios.Engine
{ {
@ -547,7 +548,15 @@ namespace Axios.Engine
public virtual void LoadRectangleItem(RectangleItemProperties rectangleitem, Layer l) public virtual void LoadRectangleItem(RectangleItemProperties rectangleitem, Layer l)
{ {
if (l.Properties.CustomProperties.Keys.Contains("Collision") && (bool)l.Properties.CustomProperties["Collision"].Value)
{
Body b = BodyFactory.CreateRectangle(this.World, ConvertUnits.ToSimUnits(rectangleitem.Width), ConvertUnits.ToSimUnits(rectangleitem.Height), 1f);
b.Position = rectangleitem.getSimPosition();
//b.Position.X +=
b.IsStatic = true;
b.BodyType = BodyType.Static;
b.UserData = this;
}
} }
public virtual void LoadTextureItem(TextureItemProperties textureitem, Layer l) public virtual void LoadTextureItem(TextureItemProperties textureitem, Layer l)

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Gleed2D.InGame;
using FarseerPhysics.SamplesFramework;
namespace Axios.Engine.Extensions
{
public static class AxiosExtensions_RectangleItemProperties
{
public static Vector2 getSimPosition(this RectangleItemProperties prop)
{
Vector2 pos = ConvertUnits.ToSimUnits(prop.Position);
pos.X += ConvertUnits.ToSimUnits(prop.Width / 2);
pos.Y += ConvertUnits.ToSimUnits(prop.Height / 2);
return pos;
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Gleed2D.InGame;
using FarseerPhysics.SamplesFramework;
namespace Axios.Engine.Extensions
{
public static class AxiosExtensions_Vector2
{
public static Vector2 toSimUnits(this Vector2 vec)
{
return ConvertUnits.ToSimUnits(vec);
}
public static Vector2 toDisplayUnits(this Vector2 vec)
{
return ConvertUnits.ToDisplayUnits(vec);
}
}
}