Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package;
- import nape.space.Space;
- import nape.phys.Body;
- import nape.phys.BodyType;
- import nape.shape.Circle;
- import nape.shape.Polygon;
- import nape.geom.Vec2;
- import nape.util.BitmapDebug;
- import FixedStep;
- class LineControl extends FixedStep {
- static function main() new LineControl()
- function new() {
- super(1/60);
- var space = new Space(new Vec2(0,400));
- var debug = new BitmapDebug(550,400,0xffffff);
- addChild(debug.display);
- var player = new Body();
- player.shapes.add(new Polygon(Polygon.box(20,20)));
- player.space = space;
- player.position.setxy(275,100);
- player.allowRotation = false;
- var floor = new Body(BodyType.STATIC);
- floor.shapes.add(new Polygon(Polygon.rect(275-100,200,200,50)));
- floor.space = space;
- var inf = Math.POSITIVE_INFINITY;
- var horiz = new nape.constraint.LineJoint(space.world, player, new Vec2(), new Vec2(), new Vec2(0,1), -inf,inf);
- horiz.stiff = false;
- horiz.maxError = 0;
- horiz.maxForce = 1000;
- horiz.space = space;
- run(function (dt) {
- player.kinematicVel.x = 100*Math.cos(space.elapsedTime);
- debug.clear();
- space.step(dt);
- debug.draw(space);
- debug.flush();
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment