public void PhysicsCallback(CollisionManager.CollisionComponent mine, CollisionManager.CollisionComponent other, CollResult coll, int collNumber) { if (other.CheckFlag(CollisionManager.FLAGS.GROUND)) { //Move position to above the path (bottom of collision should be above the ground. Above being relative to normal //set velocity to be speed magnitude perpendicular to normal of the primitive it's colliding against, } }
void SuperHackyLevelParsing() { foreach (GLEED2D.Layer layer in testLevel.Layers) { if (layer.Name.ToLower() == "collision") { //For now only process this layer //All items on this layer should be either a path, circle, or AABB foreach (GLEED2D.Item item in layer.Items) { //I don't like this, it's fine for when they were serialized out but not for loading them. //One size does not fit all if (item.GetType() == typeof(GLEED2D.PathItem)) { CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionPath((GLEED2D.PathItem)item)); } else if (item.GetType() == typeof(GLEED2D.RectangleItem)) { GLEED2D.RectangleItem gleeRect = (GLEED2D.RectangleItem)item; Rectangle zeRect = new Rectangle((int)gleeRect.Position.X, (int)gleeRect.Position.Y, (int)gleeRect.Width, (int)gleeRect.Height); CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionAABB(zeRect)); } else if (item.GetType() == typeof(GLEED2D.CircleItem)) { GLEED2D.CircleItem gleeCircle = (GLEED2D.CircleItem)item; CollisionManager.CollisionComponent foo = CollisionManager.Get().GetCollComponent(); EntityManager.Transform footrans = EntityManager.get().GetTransform(); footrans.Set(item.Position, Vector2.Zero, Vector2.Zero, 0); item.Position = Vector2.Zero; foo.SetTransform(footrans); foo.AddPrimitive(new zCollisionCircle(gleeCircle.Position, gleeCircle.Radius)); } } } } }
public override void Init(ContentManager content) { base.Init(content); //Better would be to give it a handle to the texture, but this works for now m_tex = content.Load<Texture2D>("dude"); transform.SetMaxSpeed(100.0f); myComp = CollisionManager.Get().GetCollComponent(); zCollisionCircle prim = new zCollisionCircle(Vector2.Zero, 5.0f); myComp.AddPrimitive(prim); myComp.SetTransform(transform); myComp.SetCallBack(PhysicsCallback); rayCast = CollisionManager.Get().GetCollComponent(); //zCollisionLine line = new zCollisionLine(Vector2.Zero, new Vector2(0, -1)); //rayCast.AddPrimitive(line); rayCast.SetTransform(transform); rayCast.SetCallBack(RayCastCallBack); }
public override void Init(ContentManager content) { base.Init(content); //Better would be to give it a handle to the texture, but this works for now m_tex = content.Load <Texture2D>("dude"); transform.SetMaxSpeed(100.0f); myComp = CollisionManager.Get().GetCollComponent(); zCollisionCircle prim = new zCollisionCircle(Vector2.Zero, 5.0f); myComp.AddPrimitive(prim); myComp.SetTransform(transform); myComp.SetCallBack(PhysicsCallback); rayCast = CollisionManager.Get().GetCollComponent(); //zCollisionLine line = new zCollisionLine(Vector2.Zero, new Vector2(0, -1)); //rayCast.AddPrimitive(line); rayCast.SetTransform(transform); rayCast.SetCallBack(RayCastCallBack); }
public void RayCastCallBack(CollisionManager.CollisionComponent mine, CollisionManager.CollisionComponent other, CollResult coll, int collNumber) { if (other.CheckFlag(CollisionManager.FLAGS.GROUND)) { } }