public Matrix4 setToLookAt (Vector3 position, Vector3 target, Vector3 up) {\r
tmpVec.set(target).sub(position);\r
setToLookAt(tmpVec, up);\r
- this.mul(tmpMat.setToTranslation(position.tmp().mul(-1)));\r
+ this.mul(tmpMat.setToTranslation(position.tmp().scl(-1)));\r
\r
return this;\r
}\r
processKeys();\r
\r
accel.y = -GRAVITY;\r
- accel.mul(deltaTime);\r
+ accel.scl(deltaTime);\r
vel.add(accel.x, accel.y);\r
if (accel.x == 0) vel.x *= DAMP;\r
if (vel.x > MAX_VEL) vel.x = MAX_VEL;\r
if (vel.x < -MAX_VEL) vel.x = -MAX_VEL;\r
- vel.mul(deltaTime);\r
+ vel.scl(deltaTime);\r
tryMove();\r
- vel.mul(1.0f / deltaTime);\r
+ vel.scl(1.0f / deltaTime);\r
\r
if (state == SPAWN) {\r
if (stateTime > 0.4f) {\r
if (map.bob.dir == Bob.LEFT) target.x++;\r
target.y += 0.2f;\r
\r
- vel.set(target).sub(pos).mul(Math.min(4, pos.dst(target)) * deltaTime);\r
- if (vel.len() > MAX_VELOCITY) vel.nor().mul(MAX_VELOCITY);\r
+ vel.set(target).sub(pos).scl(Math.min(4, pos.dst(target)) * deltaTime);\r
+ if (vel.len() > MAX_VELOCITY) vel.nor().scl(MAX_VELOCITY);\r
tryMove();\r
}\r
\r
if (state == CONTROLLED) {\r
- accel.mul(deltaTime);\r
+ accel.scl(deltaTime);\r
vel.add(accel.x, accel.y);\r
if (accel.x == 0) vel.x *= DAMP;\r
if (accel.y == 0) vel.y *= DAMP;\r
if (vel.x < -MAX_VELOCITY) vel.x = -MAX_VELOCITY;\r
if (vel.y > MAX_VELOCITY) vel.y = MAX_VELOCITY;\r
if (vel.y < -MAX_VELOCITY) vel.y = -MAX_VELOCITY;\r
- vel.mul(deltaTime);\r
+ vel.scl(deltaTime);\r
tryMove();\r
- vel.mul(1.0f / deltaTime);\r
+ vel.scl(1.0f / deltaTime);\r
}\r
\r
if (state == FIXED) {\r
pos.x -= vel.x * deltaTime;\r
pos.y -= vel.y * deltaTime;\r
state = -state;\r
- vel.mul(-1);\r
- if (state == FORWARD) vel.nor().mul(FORWARD_VEL);\r
- if (state == BACKWARD) vel.nor().mul(BACKWARD_VEL);\r
+ vel.scl(-1);\r
+ if (state == FORWARD) vel.nor().scl(FORWARD_VEL);\r
+ if (state == BACKWARD) vel.nor().scl(BACKWARD_VEL);\r
}\r
\r
bounds.x = pos.x;\r
// if(pos.dst(map.bob.pos) < pos.dst(map.cube.pos)) vel.set(map.bob.pos);\r
// else vel.set(map.cube.pos);\r
vel.set(map.bob.pos);\r
- vel.sub(pos).nor().mul(VELOCITY);\r
+ vel.sub(pos).nor().scl(VELOCITY);\r
pos.add(vel.x * deltaTime, vel.y * deltaTime);\r
bounds.x = pos.x + 0.2f;\r
bounds.y = pos.y + 0.2f;\r
public Array<Vector2> generatePositions(int n) {\r
Array<Vector2> positions = new Array<Vector2>();\r
for (int i = 1; i <= n; ++i) {\r
- positions.add(new Vector2(MathUtils.cos(i / n), MathUtils.sin(i / n)).mul(200));\r
+ positions.add(new Vector2(MathUtils.cos(i / n), MathUtils.sin(i / n)).scl(200));\r
}\r
return positions;\r
}\r
collisionPoints.get(2).set( this.getVertices()[10], this.getVertices()[11]);
collisionPoints.get(3).set( this.getVertices()[15], this.getVertices()[16]);
- collisionCenter.set(collisionPoints.get(2)).mul(0.5f).add(collisionPoints.get(0));
+ collisionCenter.set(collisionPoints.get(2)).scl(0.5f).add(collisionPoints.get(0));
- velocity.mul( (float) Math.pow(0.97f, delta * 30.f));
+ velocity.scl( (float) Math.pow(0.97f, delta * 30.f));
position.add(velocity.x * delta, velocity.y * delta);
this.setRotation(facing.angle());
public void goTowardsOrAway(Vector2 targetPos, boolean forceThrust, boolean isAway) {
target_direction.set(targetPos).sub(collisionCenter);
if (isAway) {
- target_direction.mul(-1);
+ target_direction.scl(-1);
}
if (facing.crs(target_direction) > 0) {
since_alive += delta;
facing.rotate((SPEED + random_speed) * delta).nor();
- position.add(facing.mul((SPEED + random_speed) * delta));
+ position.add(facing.scl((SPEED + random_speed) * delta));
this.setPosition(position.x, position.y);
if (since_alive < FADE_TIME) {
public Bomb(int id, Vector2 position, Vector2 facing) {
super(id, position, facing);
bulletSpeed = 150;
- this.velocity = new Vector2().set(facing).mul(bulletSpeed);
+ this.velocity = new Vector2().set(facing).scl(bulletSpeed);
damage = 300;
this.set(Resources.getInstance().bomb);
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import de.swagner.paxbritannica.Bullet;
-import de.swagner.paxbritannica.GameInstance;
import de.swagner.paxbritannica.Resources;
public class Laser extends Bullet {
bulletSpeed = 1000;
damage = 10;
- this.velocity = new Vector2().set(facing).mul(bulletSpeed);
+ this.velocity = new Vector2().set(facing).scl(bulletSpeed);
this.set(Resources.getInstance().laser);
this.setOrigin(0,0);
@Override
public void draw(SpriteBatch spriteBatch) {
delta = Math.min(0.06f, Gdx.graphics.getDeltaTime());
- velocity.mul( (float) Math.pow(1.03f, delta * 30.f));
+ velocity.scl( (float) Math.pow(1.03f, delta * 30.f));
super.draw(spriteBatch);
}
if (target != null) {
Vector2 random = new Vector2(MathUtils.cos((float) ((MathUtils.random() * MathUtils.PI * 2) * Math.sqrt(MathUtils.random()))),
MathUtils.sin((float) ((MathUtils.random() * MathUtils.PI * 2) * Math.sqrt(MathUtils.random()))));
- target_fuzzy_pos.set(target.collisionCenter).add(random.mul(250));
+ target_fuzzy_pos.set(target.collisionCenter).add(random.scl(250));
}
}
turnSpeed = 300f;
accel = 300.0f;
bulletSpeed = 50;
- this.velocity = new Vector2().set(facing).mul(bulletSpeed);
+ this.velocity = new Vector2().set(facing).scl(bulletSpeed);
damage = 50;
this.set(Resources.getInstance().missile);
toTarget.set(target.collisionCenter).sub(missile.collisionCenter);
if (missile.velocity.dot(toTarget) != 0) {
float time_to_target = toTarget.dot(toTarget) / relativeVel.dot(toTarget);
- return new Vector2(target.collisionCenter).sub(relativeVel.mul(Math.max(0, time_to_target)));
+ return new Vector2(target.collisionCenter).sub(relativeVel.scl(Math.max(0, time_to_target)));
} else {
return target.collisionCenter;
}
(float) (MathUtils.sin(MathUtils.random() * MathUtils.PI * 2f) * Math.sqrt(MathUtils.random())));
for (int i = 1; i <= 20; ++i) {
Vector2 vel = new Vector2().set(random).add(random);
- Vector2 velp = new Vector2().set(vel).mul(i / 20.f * 2.f);
- Vector2 offset = new Vector2().set(random).mul(10);
+ Vector2 velp = new Vector2().set(vel).scl(i / 20.f * 2.f);
+ Vector2 offset = new Vector2().set(random).scl(10);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), velp);
}
for (int i = 1; i <= 5; ++i) {
- Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).mul(4);
- Vector2 offset = new Vector2().set(random).mul(3);
+ Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).scl(4);
+ Vector2 offset = new Vector2().set(random).scl(3);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), vel);
}
for (int i = 1; i <= 50; ++i) {
- Vector2 offset = new Vector2().set(random).mul(17);
+ Vector2 offset = new Vector2().set(random).scl(17);
GameInstance.getInstance().bigBubbleParticles.addParticle(new Vector2(position.x + offset.x, position.y + offset.y));
}
}
(float) (MathUtils.sin(MathUtils.random() * MathUtils.PI * 2f) * Math.sqrt(MathUtils.random())));
for (int i = 1; i <= 10; ++i) {
Vector2 vel = new Vector2().set(random).add(random);
- Vector2 velp = new Vector2().set(vel).mul(i / 20.f * 2.f);
- Vector2 offset = new Vector2().set(random).mul(10);
+ Vector2 velp = new Vector2().set(vel).scl(i / 20.f * 2.f);
+ Vector2 offset = new Vector2().set(random).scl(10);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), velp);
}
for (int i = 1; i <= 3; ++i) {
- Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).mul(3);
- Vector2 offset = new Vector2().set(random).mul(3);
+ Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).scl(3);
+ Vector2 offset = new Vector2().set(random).scl(3);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), vel);
}
for (int i = 1; i <= 20; ++i) {
- Vector2 offset = new Vector2().set(random).mul(2);
+ Vector2 offset = new Vector2().set(random).scl(2);
GameInstance.getInstance().bigBubbleParticles.addParticle(new Vector2(position.x + offset.x, position.y + offset.y));
}
}
(float) (MathUtils.sin(MathUtils.random() * MathUtils.PI * 2f) * Math.sqrt(MathUtils.random())));
for (int i = 1; i <= 2; ++i) {
Vector2 vel = new Vector2().set(random).add(random);
- Vector2 velp = new Vector2().set(vel).mul(i / 20.f * 2.f);
- Vector2 offset = new Vector2().set(random).mul(10);
+ Vector2 velp = new Vector2().set(vel).scl(i / 20.f * 2.f);
+ Vector2 offset = new Vector2().set(random).scl(10);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), velp);
}
for (int i = 1; i <= 2; ++i) {
- Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).mul(2);
- Vector2 offset = new Vector2().set(random).mul(3);
+ Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1).scl(2);
+ Vector2 offset = new Vector2().set(random).scl(3);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), vel);
}
for (int i = 1; i <= 10; ++i) {
- Vector2 offset = new Vector2().set(random).mul(2);
+ Vector2 offset = new Vector2().set(random).scl(2);
GameInstance.getInstance().bigBubbleParticles.addParticle(new Vector2(position.x + offset.x, position.y + offset.y));
}
}
(float) (MathUtils.sin(MathUtils.random() * MathUtils.PI * 2f) * Math.sqrt(MathUtils.random())));
for (int i = 1; i <= 1; ++i) {
Vector2 vel = new Vector2().set(random).add(random);
- Vector2 velp = new Vector2().set(vel).mul(i / 20.f * 2.f);
- Vector2 offset = new Vector2().set(random).mul(10);
+ Vector2 velp = new Vector2().set(vel).scl(i / 20.f * 2.f);
+ Vector2 offset = new Vector2().set(random).scl(10);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), velp);
}
for (int i = 1; i <= 1; ++i) {
Vector2 vel = new Vector2(MathUtils.random() * 2 - 1, MathUtils.random() * 2 - 1);
- Vector2 offset = new Vector2().set(random).mul(3);
+ Vector2 offset = new Vector2().set(random).scl(3);
GameInstance.getInstance().sparkParticles.addLaserExplosion(new Vector2(position.x + offset.x, position.y + offset.y), vel);
}
for (int i = 1; i <= 5; ++i) {
- Vector2 offset = new Vector2().set(random).mul(17);
+ Vector2 offset = new Vector2().set(random).scl(17);
GameInstance.getInstance().bigBubbleParticles.addParticle(new Vector2(position.x + offset.x, position.y + offset.y));
}
}
if (particle.life > 0) {
particle.life -= delta;
particle.position.add(particle.velocity.x * delta*10,particle.velocity.y * delta*10);
- particle.velocity.mul((float) Math.pow(damping, delta));
+ particle.velocity.scl((float) Math.pow(damping, delta));
particle.scale += this.delta_scale * delta/5f;
}
}
worldCam.unproject(dragPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0));\r
float dx = dragPoint.x - touchPoint.x;\r
float dy = dragPoint.y - touchPoint.y;\r
- joystick.set(dx, dy).mul(JOYSTICK_DISTANCE_MULTIPLIER);\r
+ joystick.set(dx, dy).scl(JOYSTICK_DISTANCE_MULTIPLIER);\r
float len = joystick.len();\r
if (len > 1) {\r
joystick.nor();\r
\r
private float calculateAngle (float a) {\r
Vector3 camPos = calculateDirection(a);\r
- position.set(camPos.mul(30));\r
+ position.set(camPos.scl(30));\r
lookAt(0, 0, 0);\r
normalizeUp();\r
update();\r
float t = -(start.dot(plane.getNormal()) + plane.getD()) / denom;
if (t < 0 || t > 1) return false;
- intersection.set(start).add(dir.mul(t));
+ intersection.set(start).add(dir.scl(t));
return true;
}
else if (t > 1.0f) return point.dst(end); // Beyond 'end'-end of the segment
tmp.set(end.x, end.y, 0); // Projection falls on the segment
- tmp.sub(start.x, start.y, 0).mul(t).add(start.x, start.y, 0);
+ tmp.sub(start.x, start.y, 0).scl(t).add(start.x, start.y, 0);
return tmp2.set(point.x, point.y, 0).dst(tmp);
}
} else if (u >= l) {
tmp2.set(end.x, end.y, 0);
} else {
- tmp3.set(tmp.mul(u)); // remember tmp is already normalized
+ tmp3.set(tmp.scl(u)); // remember tmp is already normalized
tmp2.set(tmp3.x + start.x, tmp3.y + start.y, 0);
}
u /= d * d;
if (u < 0 || u > 1) return Float.POSITIVE_INFINITY;
tmp.set(end.x, end.y, 0).sub(start.x, start.y, 0);
- tmp2.set(start.x, start.y, 0).add(tmp.mul(u));
+ tmp2.set(start.x, start.y, 0).add(tmp.scl(u));
d = tmp2.dst(point.x, point.y, 0);
if (d < radius) {
displacement.set(point).sub(tmp2.x, tmp2.y).nor();
float t = -(ray.origin.dot(plane.getNormal()) + plane.getD()) / denom;
if (t < 0) return false;
- if (intersection != null) intersection.set(ray.origin).add(ray.direction.tmp().mul(t));
+ if (intersection != null) intersection.set(ray.origin).add(ray.direction.tmp().scl(t));
return true;
} else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) {
if (intersection != null) intersection.set(ray.origin);
float denom = direction.dot(plane.getNormal());
if (denom != 0) {
float t = -(origin.dot(plane.getNormal()) + plane.getD()) / denom;
- if (t >= 0 && t <= 1 && intersection != null) intersection.set(origin).add(direction.mul(t));
+ if (t >= 0 && t <= 1 && intersection != null) intersection.set(origin).add(direction.scl(t));
return t;
} else if (plane.testPoint(origin) == Plane.PlaneSide.OnPlane) {
if (intersection != null) intersection.set(origin);
// if t0 is less than zero, the intersection point is at t1
if (t0 < 0) {
- if (intersection != null) intersection.set(start).add(dir.tmp().mul(t1));
+ if (intersection != null) intersection.set(start).add(dir.tmp().scl(t1));
return true;
}
// else the intersection point is at t0
else {
- if (intersection != null) intersection.set(start).add(dir.tmp().mul(t0));
+ if (intersection != null) intersection.set(start).add(dir.tmp().scl(t0));
return true;
}
}
if (ray.origin.x <= box.min.x && ray.direction.x > 0) {
t = (box.min.x - ray.origin.x) / ray.direction.x;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.y >= box.min.y && Vector3.tmp3.y <= box.max.y && Vector3.tmp3.z >= box.min.z
&& Vector3.tmp3.z <= box.max.z && (!hit || t < lowest)) {
hit = true;
if (ray.origin.x >= box.max.x && ray.direction.x < 0) {
t = (box.max.x - ray.origin.x) / ray.direction.x;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.y >= box.min.y && Vector3.tmp3.y <= box.max.y && Vector3.tmp3.z >= box.min.z
&& Vector3.tmp3.z <= box.max.z && (!hit || t < lowest)) {
hit = true;
if (ray.origin.y <= box.min.y && ray.direction.y > 0) {
t = (box.min.y - ray.origin.y) / ray.direction.y;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.x >= box.min.x && Vector3.tmp3.x <= box.max.x && Vector3.tmp3.z >= box.min.z
&& Vector3.tmp3.z <= box.max.z && (!hit || t < lowest)) {
hit = true;
if (ray.origin.y >= box.max.y && ray.direction.y < 0) {
t = (box.max.y - ray.origin.y) / ray.direction.y;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.x >= box.min.x && Vector3.tmp3.x <= box.max.x && Vector3.tmp3.z >= box.min.z
&& Vector3.tmp3.z <= box.max.z && (!hit || t < lowest)) {
hit = true;
if (ray.origin.z <= box.min.y && ray.direction.z > 0) {
t = (box.min.z - ray.origin.z) / ray.direction.z;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.x >= box.min.x && Vector3.tmp3.x <= box.max.x && Vector3.tmp3.y >= box.min.y
&& Vector3.tmp3.y <= box.max.y && (!hit || t < lowest)) {
hit = true;
if (ray.origin.z >= box.max.z && ray.direction.z < 0) {
t = (box.max.z - ray.origin.z) / ray.direction.z;
if (t >= 0) {
- Vector3.tmp3.set(ray.direction).mul(t).add(ray.origin);
+ Vector3.tmp3.set(ray.direction).scl(t).add(ray.origin);
if (Vector3.tmp3.x >= box.min.x && Vector3.tmp3.x <= box.max.x && Vector3.tmp3.y >= box.min.y
&& Vector3.tmp3.y <= box.max.y && (!hit || t < lowest)) {
hit = true;
}
}
if (hit && intersection != null) {
- intersection.set(ray.direction).mul(lowest).add(ray.origin);
+ intersection.set(ray.direction).scl(lowest).add(ray.origin);
}
return hit;
}
public Matrix4 setToLookAt (Vector3 position, Vector3 target, Vector3 up) {\r
tmpVec.set(target).sub(position);\r
setToLookAt(tmpVec, up);\r
- this.mul(tmpMat.setToTranslation(position.tmp().mul(-1)));\r
+ this.mul(tmpMat.setToTranslation(position.tmp().scl(-1)));\r
\r
return this;\r
}\r
}\r
\r
public Vector2 div (float value) {\r
- return this.mul(1 / value);\r
+ return this.scl(1 / value);\r
}\r
\r
public Vector2 div (float vx, float vy) {\r
- return this.mul(1 / vx, 1 / vy);\r
+ return this.scl(1 / vx, 1 / vy);\r
}\r
\r
public Vector2 div (Vector2 other) {\r
- return this.mul(1 / other.x, 1 / other.y);\r
+ return this.scl(1 / other.x, 1 / other.y);\r
}\r
\r
/** @param v The other vector\r
public Vector2 limit (float limit) {\r
if (len2() > limit * limit) {\r
nor();\r
- mul(limit);\r
+ scl(limit);\r
}\r
return this;\r
}\r
if (l2 == 0f)\r
return this;\r
if (l2 > max * max)\r
- return nor().mul(max);\r
+ return nor().scl(max);\r
if (l2 < min * min)\r
- return nor().mul(min);\r
+ return nor().scl(min);\r
return this;\r
}\r
\r
minimum.z < maximum.z ? minimum.z : maximum.z);\r
max.set(minimum.x > maximum.x ? minimum.x : maximum.x, minimum.y > maximum.y ? minimum.y : maximum.y,\r
minimum.z > maximum.z ? minimum.z : maximum.z);\r
- cnt.set(min).add(max).mul(0.5f);\r
+ cnt.set(min).add(max).scl(0.5f);\r
dim.set(max).sub(min);\r
crn_dirty = true;\r
return this;\r
* @param distance The distance from the end point to the start point.\r
* @return The end point */\r
public Vector3 getEndPoint (float distance) {\r
- return new Vector3(origin).add(direction.tmp().mul(distance));\r
+ return new Vector3(origin).add(direction.tmp().scl(distance));\r
}\r
\r
static Vector3 tmp = new Vector3();\r
if (!deadzoneBounds.contains(x, y)) {\r
knobPercent.set((x - centerX) / knobBounds.radius, (y - centerY) / knobBounds.radius);\r
float length = knobPercent.len();\r
- if (length > 1) knobPercent.mul(1 / length);\r
+ if (length > 1) knobPercent.scl(1 / length);\r
if (knobBounds.contains(x, y)) {\r
knobPosition.set(x, y);\r
} else {\r
- knobPosition.set(knobPercent).nor().mul(knobBounds.radius).add(knobBounds.x, knobBounds.y);\r
+ knobPosition.set(knobPercent).nor().scl(knobBounds.radius).add(knobBounds.x, knobBounds.y);\r
}\r
}\r
}\r
public void update (float deltaTime) {\r
dist += dir.len() * deltaTime;\r
if (dist > maxDist) {\r
- dir.mul(-1);\r
+ dir.scl(-1);\r
dist = 0;\r
}\r
\r
@Override\r
public void create () {\r
camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
- camera.position.set(0, 2, 3).nor().mul(10);\r
+ camera.position.set(0, 2, 3).nor().scl(10);\r
camera.lookAt(0, 0, 0);\r
\r
camera2 = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());\r
Vector2 getCurrentPosition () {\r
temp.set(targetPosition);\r
temp.sub(position);\r
- temp.mul(getInterpolation().apply(Math.min(1, timer / 1f)));\r
+ temp.scl(getInterpolation().apply(Math.min(1, timer / 1f)));\r
temp.add(position);\r
return temp;\r
}\r
diff.set(endPoint.x, endPoint.y).sub(bones[i + 1].position.x, bones[i + 1].position.y);\r
diff.add(0, gravity);\r
diff.add(bones[i + 1].inertia.x, bones[i + 1].inertia.y);\r
- diff.nor().mul(bones[i + 1].len);\r
+ diff.nor().scl(bones[i + 1].len);\r
\r
float x = endPoint.x - diff.x;\r
float y = endPoint.y - diff.y;\r
float delta = Gdx.graphics.getDeltaTime();\r
- bones[i + 1].inertia.add((bones[i + 1].position.x - x) * delta, (bones[i + 1].position.y - y) * delta, 0).mul(0.99f);\r
+ bones[i + 1].inertia.add((bones[i + 1].position.x - x) * delta, (bones[i + 1].position.y - y) * delta, 0).scl(0.99f);\r
bones[i + 1].position.set(x, y, 0);\r
}\r
}\r
float pixelsOnX = Gdx.graphics.getWidth() / unitsOnX;\r
float unitsOnY = Gdx.graphics.getHeight() / pixelsOnX;\r
cam = new OrthographicCamera(unitsOnX, unitsOnY, 25);\r
- cam.position.mul(30);\r
+ cam.position.scl(30);\r
cam.near = 1;\r
cam.far = 1000;\r
matrix.setToRotation(new Vector3(1, 0, 0), 90);\r
}\r
\r
if (input.isKeyPressed(Keys.W)) {\r
- Vector3 forward = new Vector3().set(camera.direction).mul(delta);\r
+ Vector3 forward = new Vector3().set(camera.direction).scl(delta);\r
camera.position.add(forward);\r
}\r
if (input.isKeyPressed(Keys.S)) {\r
- Vector3 backward = new Vector3().set(camera.direction).mul(delta);\r
+ Vector3 backward = new Vector3().set(camera.direction).scl(delta);\r
camera.position.sub(backward);\r
}\r
\r
if (input.isKeyPressed(Keys.A)) {\r
- Vector3 left = new Vector3().set(camera.direction.cpy().crs(camera.up).nor()).mul(delta);\r
+ Vector3 left = new Vector3().set(camera.direction.cpy().crs(camera.up).nor()).scl(delta);\r
camera.position.sub(left);\r
}\r
if (input.isKeyPressed(Keys.D)) {\r
- Vector3 right = new Vector3().set(camera.direction.cpy().crs(camera.up).nor()).mul(delta);\r
+ Vector3 right = new Vector3().set(camera.direction.cpy().crs(camera.up).nor()).scl(delta);\r
camera.position.add(right);\r
}\r
\r
- Vector3 forward = new Vector3().set(camera.direction).mul(delta);\r
+ Vector3 forward = new Vector3().set(camera.direction).scl(delta);\r
camera.position.add(forward);\r
int nextId = (MathUtils.floor(camera.position.x) * 33) + MathUtils.floor(camera.position.z);\r
// are we still on our current chunk ? - maybe switching to another chunk\r
Body body1 = world.createBody(triangleBodyDef);\r
body1.createFixture(triangleShapeDef);\r
\r
- vertices[0].mul(2);\r
- vertices[1].mul(2);\r
- vertices[2].mul(2);\r
+ vertices[0].scl(2);\r
+ vertices[1].scl(2);\r
+ vertices[2].scl(2);\r
\r
polygon.set(vertices);\r
triangleShapeDef.filter.groupIndex = k_largeGroup;\r
Ray ray = camera.getPickRay(x, y);
BulletEntity entity = world.add(what, ray.origin.x, ray.origin.y, ray.origin.z);
entity.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
- ((btRigidBody)entity.body).applyCentralImpulse(ray.direction.mul(impulse));
+ ((btRigidBody)entity.body).applyCentralImpulse(ray.direction.scl(impulse));
return entity;
}
public boolean tap (float x, float y, int count, int button) {
Ray ray = camera.getPickRay(x, y);
rayFrom.set(ray.origin);
- rayTo.set(ray.direction).mul(50f).add(rayFrom); // 50 meters max from the origin
+ rayTo.set(ray.direction).scl(50f).add(rayFrom); // 50 meters max from the origin
// Because we reuse the ClosestRayResultCallback, we need reset it's values
rayTestCB.setM_collisionObject(null);
if (!obj.isStaticOrKinematicObject()) {
final btRigidBody body = btRigidBody.upcast(obj);
body.activate();
- body.applyCentralImpulse(Vector3.tmp2.set(ray.direction).mul(20f));
+ body.applyCentralImpulse(Vector3.tmp2.set(ray.direction).scl(20f));
}
}
return true;
boolean result = false;
if (button == Buttons.LEFT) {
Ray ray = camera.getPickRay(screenX, screenY);
- Vector3.tmp.set(ray.direction).mul(10f).add(ray.origin);
+ Vector3.tmp.set(ray.direction).scl(10f).add(ray.origin);
ClosestRayResultCallback cb = new ClosestRayResultCallback(ray.origin, Vector3.tmp);
world.collisionWorld.rayTest(ray.origin, Vector3.tmp, cb);
if (cb.hasHit()) {
boolean result = false;
if (pickConstraint != null) {
Ray ray = camera.getPickRay(screenX, screenY);
- Vector3.tmp.set(ray.direction).mul(pickDistance).add(camera.position);
+ Vector3.tmp.set(ray.direction).scl(pickDistance).add(camera.position);
pickConstraint.setPivotB(Vector3.tmp);
result = true;
}
\r
// multiply by delta time so we know how far we go\r
// in this frame\r
- koala.velocity.mul(deltaTime);\r
+ koala.velocity.scl(deltaTime);\r
\r
// perform collision detection & response, on each axis, separately\r
// if the koala is moving right, check the tiles to the right of it's\r
// unscale the velocity by the inverse delta time and set \r
// the latest position\r
koala.position.add(koala.velocity);\r
- koala.velocity.mul(1/deltaTime);\r
+ koala.velocity.scl(1/deltaTime);\r
\r
// Apply damping to the velocity on the x-axis so we don't\r
// walk infinitely once a key was pressed\r