Skip to content

Commit

Permalink
feat(league): fix simultetris placement + activate simultris by defau…
Browse files Browse the repository at this point in the history
…lt + some refactoring
  • Loading branch information
timotheeg committed Oct 14, 2024
1 parent 1b475fd commit 5ecadb6
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions public/views/mp/league.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
display: none;
position: absolute;
transform-origin: 50% 50%;
top: 150px;
top: 400px;
--offset: 341px;
right: var(--offset);
}
Expand Down Expand Up @@ -332,12 +332,13 @@
import CompetitionPlayer from '/views/CompetitionPlayer.js';
import Competition from '/views/competition.js';
import InvisibleMixin from '/views/InvisibleMixin.js';
import { easeOutElastic } from '/js/anim.js';
import { easeOutElastic, getRandomAngle } from '/js/anim.js';

const SHOW_SIMUL_TETRIS = /^[1-9]\d*$/.test(QueryString.get('simultris'));
const SIMUL_TETRIS_DELAY = SHOW_SIMUL_TETRIS
? parseInt(QueryString.get('simultris'), 10)
: 120;
const SHOW_SIMUL_TETRIS = QueryString.get('simultris') !== '0';
const SIMUL_TETRIS_DELAY =
SHOW_SIMUL_TETRIS && /^[1-9]\d*$/.test(QueryString.get('simultris'))
? parseInt(QueryString.get('simultris'), 10)
: 120;

// supply 0 to disable
const CYCLE_TDIFF = /^\d+$/.test(QueryString.get('cycle_tdiff'))
Expand Down Expand Up @@ -453,20 +454,19 @@
// clear all ongoing simul-tetris timers for this match
while (sync_timers.length) clearTimeout(sync_timers.pop());

const start_time = Date.now();
const scale_start = 0;
const duration = 750;

match_players.forEach(player => {
window.cancelAnimationFrame(player.animationId);

// show the simul-tetris sign
const scale_start = 0;
const scale_end = 0.85 + Math.random() * 0.1;
const scale_change = scale_end - scale_start;
const angle = -10 + Math.random() * 20;
const duration = 750;
const angle = getRandomAngle(2, 10);

player.dom.simul_tetris.style.display = 'inline';
player.dom.simul_tetris.style.transform = `scale(${scale_start}) rotate(${angle}deg)`;

const start_time = Date.now();

function step() {
const elapsed = Date.now() - start_time;
Expand All @@ -490,7 +490,7 @@
}
}

player.animationId = window.requestAnimationFrame(step);
step();
});
}
};
Expand Down

0 comments on commit 5ecadb6

Please sign in to comment.