private void clampVelocity(Physics physics, float minSpeed, float maxSpeed) { vTmp.set(physics.vx, physics.vy).clamp(minSpeed,maxSpeed); physics.vx = vTmp.x; physics.vy = vTmp.y; }
private void clampVelocity(Physics physics, float minSpeed, float maxSpeed) { vTmp.set(physics.vx, physics.vy).clamp(minSpeed,maxSpeed); physics.vx = vTmp.x; physics.vy = vTmp.y; }
private void clampVelocity(Physics physics, float minSpeed, float maxSpeed) { vTmp.set(physics.vx, physics.vy).clamp(minSpeed,maxSpeed); physics.vx = vTmp.x; physics.vy = vTmp.y; }
/** * Apply force on joint, pushing the attached entity out of place. * * @param attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
/** * Apply force on joint, pushing the attached entity out of place. * * @param attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
/** * Apply force on joint, pushing the attached entity out of place. * * @param Attached Attached component of entity to push * @param rotation Direction of force * @param force strength of force (don't factor in delta). */ public void push(final Attached attached, float rotation, float force) { vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack); attached.slackX = vTmp.x; attached.slackY = vTmp.y; }
/** * Draws a dotted line between to points (x1,y1) and (x2,y2). * @param shapeRenderer * @param dotDist (distance between dots) * @param x1 * @param y1 * @param x2 * @param y2 */ private void drawDottedLine(ShapeRenderer shapeRenderer, int dotDist, float x1, float y1, float x2, float y2) { shapeRenderer.begin(ShapeType.Point); Vector2 vec2 = new Vector2(x2, y2).sub(new Vector2(x1, y1)); float length = vec2.len(); for(int i = 0; i < length; i += dotDist) { vec2.clamp(length - i, length - i); shapeRenderer.point(x1 + vec2.x, y1 + vec2.y, 0); } shapeRenderer.end(); }
@Override protected void process(int e) { final Inbetween inbetween = dm.get(e); final int entityA = inbetween.a; final int entityB = inbetween.b; if ( entityA == -1 || entityB == -1 ) return; Pos pos1 = pm.get(entityA); Pos pos2 = pm.get(entityB); tmp.set(pos2.xy.x + inbetween.bx, pos2.xy.y + inbetween.by).sub(pos1.xy.x + inbetween.ax, pos1.xy.y + inbetween.ay).scl(inbetween.tween).clamp(0,inbetween.maxDistance).add(pos1.xy.x + inbetween.ax,pos1.xy.y + inbetween.ay); Pos pos = pm.get(e); pos.xy.x = tmp.x; pos.xy.y = tmp.y; } }
@Override protected void process(int e) { final Inbetween inbetween = dm.get(e); final int entityA = inbetween.a; final int entityB = inbetween.b; if ( entityA == -1 || entityB == -1 ) return; Pos pos1 = pm.get(entityA); Pos pos2 = pm.get(entityB); tmp.set(pos2.xy.x + inbetween.bx, pos2.xy.y + inbetween.by).sub(pos1.xy.x + inbetween.ax, pos1.xy.y + inbetween.ay).scl(inbetween.tween).clamp(0,inbetween.maxDistance).add(pos1.xy.x + inbetween.ax,pos1.xy.y + inbetween.ay); Pos pos = pm.get(e); pos.xy.x = tmp.x; pos.xy.y = tmp.y; } }
@Override protected void process(Entity e) { final Inbetween inbetween = dm.get(e); if ( !inbetween.a.isActive() || !inbetween.b.isActive() ) return; Pos pos1 = pm.get(inbetween.a.get()); Pos pos2 = pm.get(inbetween.b.get()); tmp.set(pos2.x + inbetween.bx, pos2.y + inbetween.by).sub(pos1.x + inbetween.ax, pos1.y + inbetween.ay).scl(inbetween.tween).clamp(0,inbetween.maxDistance).add(pos1.x + inbetween.ax,pos1.y + inbetween.ay); Pos pos = pm.get(e); pos.x = tmp.x; pos.y = tmp.y; } }
velocity.y += delta * accelerationY; velocity.clamp(0, MAX_SPEED);