@@ 517,11 517,35 @@ async function client_main(server: string, username: string, texture_quality: st
const thruster_end_a = 0;
const thruster_start_size = 4;
const thruster_end_size = 50;
-
+ const thruster_final_rotation = 90;
+
+ function createThrusterParticle(x: number, y: number, vel_x: number, vel_y: number) {
+ createParticle({
+ x: global.me!.x + calculateRotated(x, y, global.me!.rotation)[0],
+ y: global.me!.y + calculateRotated(x, y, global.me!.rotation)[1],
+ lifetime: 500,
+ timer: 0,
+ startSize: thruster_start_size,
+ finalSize: thruster_end_size,
+ startRotation: 0,
+ finalRotation: thruster_final_rotation,
+ startOpacity: thruster_start_a,
+ endOpacity: thruster_end_a,
+ startR: thruster_r,
+ startG: thruster_g,
+ startB: thruster_b,
+ endR: thruster_r,
+ endG: thruster_g,
+ endB: thruster_b,
+ velocity_x: calculateRotated(vel_x, vel_y, global.me!.rotation)[0],
+ velocity_y: calculateRotated(vel_x, vel_y, global.me!.rotation)[1]
+ });
+ }
if (global.me !== null) {
console.log(thruster_counter);
thruster_counter += 1;
+ //thruster_counter = 1; // uncomment this line to disable particle limits
if (thruster_counter > 5) {
console.log("resetting counter");
thruster_counter = 0;
@@ 530,177 554,29 @@ async function client_main(server: string, username: string, texture_quality: st
if (global.keys.up) {
// two backward thrusters
// this one is blue
- createParticle({
- x: global.me.x + calculateRotated(-25, 25, global.me.rotation)[0],
- y: global.me.y + calculateRotated(-25, 25, global.me.rotation)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
-
- // two backward thrusters
- // this one is pink
- createParticle({
- x: global.me.x + calculateRotated(25, -25, global.me.rotation + Math.PI/2)[0],
- y: global.me.y + calculateRotated(25, -25, global.me.rotation + Math.PI/2)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
+ createThrusterParticle(-25, 25, 0, 0.5);
+ createThrusterParticle(25, 25, 0, 0.5);
}
if (global.keys.down) {
// two backward thrusters
// this one is blue
- createParticle({
- x: global.me.x + calculateRotated(25, -25, global.me.rotation)[0],
- y: global.me.y + calculateRotated(25, -25, global.me.rotation)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
-
- // two backward thrusters
- // this one is pink
- createParticle({
- x: global.me.x + calculateRotated(-25, 25, global.me.rotation + Math.PI/2)[0],
- y: global.me.y + calculateRotated(-25, 25, global.me.rotation + Math.PI/2)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
+ createThrusterParticle(25, -25, 0, -0.5);
+ createThrusterParticle(-25, -25, 0, -0.5);
}
if (global.keys.left) {
// two backward thrusters
// this one is blue
- createParticle({
- x: global.me.x + calculateRotated(25, 25, global.me.rotation)[0],
- y: global.me.y + calculateRotated(25, 25, global.me.rotation)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
-
- // two backward thrusters
- // this one is pink
- createParticle({
- x: global.me.x + calculateRotated(-25, 25, global.me.rotation + Math.PI/2)[0],
- y: global.me.y + calculateRotated(-25, 25, global.me.rotation + Math.PI/2)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
+ createThrusterParticle(25, 25, 0, 0.5);
+ createThrusterParticle(-25, -25, 0, -0.5);
}
if (global.keys.right) {
// two backward thrusters
// this one is blue
- createParticle({
- x: global.me.x + calculateRotated(-25, 25, global.me.rotation)[0],
- y: global.me.y + calculateRotated(-25, 25, global.me.rotation)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
-
- // two backward thrusters
- // this one is pink
- createParticle({
- x: global.me.x + calculateRotated(-25, -25, global.me.rotation + Math.PI/2)[0],
- y: global.me.y + calculateRotated(-25, -25, global.me.rotation + Math.PI/2)[1],
- lifetime: 500,
- timer: 0,
- startSize: thruster_start_size,
- finalSize: thruster_end_size,
- startRotation: 0,
- finalRotation: 180,
- startOpacity: thruster_start_a,
- endOpacity: thruster_end_a,
- startR: thruster_r,
- startG: thruster_g,
- startB: thruster_b,
- endR: thruster_r,
- endG: thruster_g,
- endB: thruster_b
- });
+ createThrusterParticle(-25, 25, 0,0.5);
+ createThrusterParticle(25, -25, 0, -0.5);
}
}