Add instructions
This commit is contained in:
parent
60f77c36a9
commit
2959c39da7
10 changed files with 119 additions and 21 deletions
|
@ -29,7 +29,7 @@ export function createEndEditBurst(ship) {
|
|||
|
||||
export function createCrash(ship) {
|
||||
for (let i = 0; i < ship.mass + 3; i++) {
|
||||
particles.add(new Particle(...ship.poc, {
|
||||
particles.add(new Particle(...ship.com, {
|
||||
color: '#f2e860',
|
||||
lifetime: Math.random() * 50 + 40,
|
||||
size: Math.random() * 0.2 + 0.2,
|
||||
|
@ -38,7 +38,7 @@ export function createCrash(ship) {
|
|||
}));
|
||||
}
|
||||
for (let i = 0; i < ship.mass + 3; i++) {
|
||||
particles.add(new Particle(...ship.poc, {
|
||||
particles.add(new Particle(...ship.com, {
|
||||
color: '#f75722',
|
||||
lifetime: Math.random() * 50 + 40,
|
||||
size: Math.random() * 0.2 + 0.2,
|
||||
|
@ -47,7 +47,7 @@ export function createCrash(ship) {
|
|||
}));
|
||||
}
|
||||
for (let i = 0; i < ship.mass * 2 + 3; i++) {
|
||||
particles.add(new Particle(...ship.poc, {
|
||||
particles.add(new Particle(...ship.com, {
|
||||
color: '#888',
|
||||
lifetime: Math.random() * 30 + 55,
|
||||
size: Math.random() * 0.5 + 0.4,
|
||||
|
|
|
@ -161,6 +161,7 @@ export default class Ship extends Body {
|
|||
}
|
||||
|
||||
moduleCollided(module) {
|
||||
if (this.landed) return;
|
||||
let speed = Math.sqrt(this.xvel ** 2 + this.yvel ** 2);
|
||||
if (module.type !== 'thruster' || speed > consts.CRASH_SPEED) {
|
||||
events.crash();
|
||||
|
@ -202,13 +203,18 @@ export default class Ship extends Body {
|
|||
|
||||
let thrustForce = -forward * consts.THRUST_POWER * this.thrust;
|
||||
let turnForce = (turnRight - turnLeft) * consts.TURN_POWER;
|
||||
if (this.fuel <= 0) {
|
||||
this.fuel = 0;
|
||||
thrustForce = 0;
|
||||
} else {
|
||||
this.fuel -= Math.abs(thrustForce) * consts.FUEL_BURN_RATE;
|
||||
}
|
||||
turnForce *= this.rotationPower;
|
||||
this.fuel -= Math.abs(thrustForce) * consts.FUEL_BURN_RATE;
|
||||
|
||||
this.applyDirectionalForce(0, thrustForce, turnForce);
|
||||
|
||||
this.modules.forEach(m => {
|
||||
if (m.type !== 'thruster') return;
|
||||
if (m.type !== 'thruster' || thrustForce == 0) return;
|
||||
m.power += forward;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue