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:
@@ -1,26 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
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.Log;
|
||||
using Axios.Engine.Structures;
|
||||
using Axios.Engine.UI;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.SamplesFramework;
|
||||
using GameStateManagement;
|
||||
using Gleed2D.Core;
|
||||
using Gleed2D.InGame;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using GameStateManagement;
|
||||
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
|
||||
{
|
||||
@@ -547,7 +548,15 @@ namespace Axios.Engine
|
||||
|
||||
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)
|
||||
|
21
axios/Engine/Extensions/RectangleItemProperties.cs
Normal file
21
axios/Engine/Extensions/RectangleItemProperties.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
23
axios/Engine/Extensions/Vector2.cs
Normal file
23
axios/Engine/Extensions/Vector2.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user