Fewer trajectory fades
This commit is contained in:
1 parent
fdbe482ff7
commit
9095d0c6b0
2 files changed
+24
-27
No files matched your search
+11
-11
@@ -25,15 +25,15 @@ export const PLAYER_COLORS = [
|
|||||||
export const PLAYER_STARTING_WEAPONS = [
|
export const PLAYER_STARTING_WEAPONS = [
|
||||||
{type: 'babyMissile', ammo:Infinity},
|
{type: 'babyMissile', ammo:Infinity},
|
||||||
{type: 'missile', ammo:5},
|
{type: 'missile', ammo:5},
|
||||||
{type: 'babyNuke', ammo:3},
|
// {type: 'babyNuke', ammo:3},
|
||||||
{type: 'nuke', ammo:1},
|
// {type: 'nuke', ammo:1},
|
||||||
{type: 'smallDirt', ammo:5},
|
// {type: 'smallDirt', ammo:5},
|
||||||
{type: 'dirt', ammo:3},
|
// {type: 'dirt', ammo:3},
|
||||||
{type: 'largeDirt', ammo:1},
|
// {type: 'largeDirt', ammo:1},
|
||||||
{type: 'smallDigBomb', ammo:5},
|
// {type: 'smallDigBomb', ammo:5},
|
||||||
{type: 'digBomb', ammo:3},
|
// {type: 'digBomb', ammo:3},
|
||||||
{type: 'largeDigBomb', ammo:1},
|
// {type: 'largeDigBomb', ammo:1},
|
||||||
{type: 'tracer', ammo:Infinity},
|
// {type: 'tracer', ammo:Infinity},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const WEAPON_TYPES = [
|
export const WEAPON_TYPES = [
|
||||||
@@ -91,8 +91,8 @@ export const PROJECTILE_ITERATIONS_PER_FRAME = 30;
|
|||||||
export const PROJECTILE_ITERATION_PROGRESS = 0.01;
|
export const PROJECTILE_ITERATION_PROGRESS = 0.01;
|
||||||
export const PROJECTILE_MIN_SOUND_FREQUENCY = 220;
|
export const PROJECTILE_MIN_SOUND_FREQUENCY = 220;
|
||||||
export const PROJECTILE_MAX_SOUND_FREQUENCY = 2200;
|
export const PROJECTILE_MAX_SOUND_FREQUENCY = 2200;
|
||||||
export const TRAJECTORY_FADE_SPEED = 0.6;
|
export const TRAJECTORY_FADE_SPEED = 10;
|
||||||
export const TRAJECTORY_FLOAT_SPEED = 0.01;
|
export const TRAJECTORY_FLOAT_SPEED = 0.3;
|
||||||
|
|
||||||
export const PARTICLE_AMOUNT = 30;
|
export const PARTICLE_AMOUNT = 30;
|
||||||
export const PARTICLE_MIN_POWER_FACTOR = 0.4;
|
export const PARTICLE_MIN_POWER_FACTOR = 0.4;
|
||||||
|
|||||||
+13
-16
@@ -189,8 +189,6 @@ function update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fadeTrajectories(TRAJECTORY_FADE_SPEED);
|
|
||||||
|
|
||||||
let trajectory = drawLineVirtual(
|
let trajectory = drawLineVirtual(
|
||||||
prevProjectile.x, prevProjectile.y,
|
prevProjectile.x, prevProjectile.y,
|
||||||
projectile.x, projectile.y,
|
projectile.x, projectile.y,
|
||||||
@@ -286,6 +284,7 @@ function update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
projectile = null;
|
projectile = null;
|
||||||
|
fadeTrajectories();
|
||||||
state = 'start-turn';
|
state = 'start-turn';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,33 +402,31 @@ function drawPlayers() {
|
|||||||
|
|
||||||
function drawTrajectories() {
|
function drawTrajectories() {
|
||||||
traces.clearRect(0, 0, W, H);
|
traces.clearRect(0, 0, W, H);
|
||||||
for (let {x, y, c, a} of trajectories) {
|
for (let i=trajectories.length-1; i>=0; i--) {
|
||||||
traces.globalAlpha = a / 255;
|
const trajectory = trajectories[i];
|
||||||
|
const {x, y, c} = trajectory;
|
||||||
|
traces.globalAlpha = trajectory.a / 255;
|
||||||
plot(traces, x, y, c);
|
plot(traces, x, y, c);
|
||||||
}
|
}
|
||||||
traces.globalAlpha = 1;
|
traces.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawProjectile() {
|
function fadeTrajectories() {
|
||||||
if (!projectile) return;
|
|
||||||
plot(foreground, clamp(0, projectile.x, W-1), clamp(0, projectile.y, H-1), 'white');
|
|
||||||
}
|
|
||||||
|
|
||||||
function fadeTrajectories(amount) {
|
|
||||||
for (let i=trajectories.length-1; i>=0; i--) {
|
for (let i=trajectories.length-1; i>=0; i--) {
|
||||||
const trajectory = trajectories[i];
|
const trajectory = trajectories[i];
|
||||||
trajectory.a -= amount;
|
trajectory.a -= TRAJECTORY_FADE_SPEED;
|
||||||
trajectory.y -= TRAJECTORY_FLOAT_SPEED;
|
trajectory.y -= TRAJECTORY_FLOAT_SPEED;
|
||||||
|
if (trajectory.a <= 0 || trajectory.y <= 0) {
|
||||||
if (
|
|
||||||
trajectory.a <= 0 || trajectory.y <= 0 ||
|
|
||||||
isTerrain(terrain, trajectory.x, trajectory.y)
|
|
||||||
) {
|
|
||||||
trajectories.splice(i, 1);
|
trajectories.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawProjectile() {
|
||||||
|
if (!projectile) return;
|
||||||
|
plot(foreground, clamp(0, projectile.x, W-1), clamp(0, projectile.y, H-1), 'white');
|
||||||
|
}
|
||||||
|
|
||||||
function drawExplosions() {
|
function drawExplosions() {
|
||||||
if (!explosion) return;
|
if (!explosion) return;
|
||||||
const explosionType = EXPLOSION_TYPES[explosion.type];
|
const explosionType = EXPLOSION_TYPES[explosion.type];
|
||||||
|
|||||||
Reference in new issue
Block a user