Skip to content
Snippets Groups Projects
Commit 0de6714c authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

liitos

parent e42c8f19
No related branches found
No related tags found
No related merge requests found
......@@ -4,19 +4,72 @@ using Jypeli.Controls;
using Jypeli.Widgets;
using System;
using System.Collections.Generic;
using FSJoint = FarseerPhysics.Dynamics.Joints.DistanceJoint;
using FarseerPhysics.Factories;
using FarseerPhysics.Dynamics;
using Jypeli.Farseer;
using Jypeli.Physics;
using FarseerPhysics.Dynamics.Joints;
public class Liitos : PhysicsGame
{
public class AxleJoint : Jypeli.AxleJoint
{
internal FSJoint InnerJoint
{
get
{
return (FSJoint)innerJoint;
}
set
{
innerJoint = value;
}
}
/// <summary>
/// Luo uuden akseliliitoksen kahden olion välille.
/// </summary>
/// <param name="firstObject">Ensimmäinen olio</param>
/// <param name="secondObject">Toinen olio</param>
/// <param name="axlePosition">Liitoksen akselin paikka</param>
public AxleJoint(PhysicsObject firstObject, PhysicsObject secondObject, Vector axlePosition)
: base(firstObject, secondObject, axlePosition)
{
World world = PhysicsGame.Instance.Engine as World;
var first = firstObject.Body as PhysicsBody;
var second = secondObject.Body as PhysicsBody;
var ap2 = firstObject.Position + axlePosition - secondObject.Position;
InnerJoint = JointFactory.CreateDistanceJoint(world,
first.FSBody, second.FSBody,
axlePosition * FSConvert.DisplayToSim, ap2 * FSConvert.DisplayToSim);
// axlePosition2 * FSConvert.DisplayToSim);
InnerJoint.DampingRatio = 0.5f;
InnerJoint.Frequency = 50;
//InnerJoint.Enabled = false;
}
}
public override void Begin()
{
Level.Background.Color = Color.Black;
var osa1 = new PhysicsObject(200, 30);
osa1.MakeStatic();
osa1.AddCollisionIgnoreGroup(1);
Add(osa1);
var osa2 = new PhysicsObject(200, 30);
osa2.Position = new Vector(osa1.Width, 0);
osa2.AddCollisionIgnoreGroup(1);
Add(osa2);
var liitos = new AxleJoint(osa1, osa2, new Vector(osa1.Width/2, 0));
liitos.Softness = 0;
Add(liitos);
Gravity = new Vector(0, -400);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment