This commit is contained in:
Renan LE CARO 2025-05-03 20:17:49 +02:00
parent 014aea003f
commit 9e12f62b81
8 changed files with 2189 additions and 2166 deletions

View file

@ -642,18 +642,7 @@ h2.histogram-title strong {
opacity: 0.8;
transform: none;
}
&.big {
border: none;
left: 50vw;
top: 50vh;
font-size: 60px;
font-weight: bold;
opacity: 0.8;
background: none;
text-shadow: 2px 0 #000, -2px 0 #000, 0 2px #000, 0 -2px #000,
1px 1px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000;
transform: translate(-50%,-50%);
}
}
.gridEdit > div > span,

View file

@ -82,7 +82,6 @@ import { monitorLevelsUnlocks } from "./monitorLevelsUnlocks";
import { levelEditorMenuEntry } from "./levelEditor";
import { categories } from "./upgrades";
import { reasonLevelIsLocked } from "./get_level_unlock_condition";
import {clearToasts, toast} from "./toast";
export async function play() {
if (await applyFullScreenChoice()) return;
@ -254,23 +253,35 @@ gameCanvas.addEventListener("mousemove", (e) => {
let timers = [];
function startPlayCountDown() {
stopPlayCountDown();
toast("3", "big");
timers.push(setTimeout(() => toast("2", "big"), 1000));
timers.push(setTimeout(() => toast("1", "big"), 2000));
gameState.startCountDown = 3
gameState.needsRender = true
timers.push(setTimeout(() => {
gameState.startCountDown = 2
gameState.needsRender = true
}, 1000));
timers.push(setTimeout(() => {
gameState.startCountDown = 1
gameState.needsRender = true
}, 2000));
timers.push(
setTimeout(() => {
toast("GO", "big");
gameState.startCountDown = 0
play();
}, 3000),
);
timers.push(setTimeout(() => clearToasts(), 3500));
}
function stopPlayCountDown() {
if(!timers.length) return
clearToasts()
gameState.startCountDown = 0
timers.forEach((id) => clearTimeout(id));
timers.length = 0;
}
gameCanvas.addEventListener("touchstart", (e) => {
e.preventDefault();

File diff suppressed because it is too large Load diff

View file

@ -142,9 +142,9 @@ export async function openUpgradesPicker(gameState: GameState) {
const unlockable = getFirstUnlockable(gameState);
let unlockRelatedUpgradesOffered = 0;
let unlockHint = "";
const upgradesActions = offered.map((u) => {
let unlockHint = "";
let className = "";
if (isOptionOn("level_unlocks_hints")) {
if (unlockable?.forbidden?.includes(u.id) && !gameState.perks[u.id]) {

View file

@ -642,6 +642,22 @@ export function render(gameState: GameState) {
);
}
startWork("render:timeout");
if(gameState.winAt || gameState.startCountDown){
const remaining = gameState.startCountDown || Math.ceil((gameState.winAt-gameState.levelTime)/1000)
if(remaining>0 && remaining<5){
ctx.globalAlpha=1
ctx.globalCompositeOperation="destination-out";
drawText(ctx, remaining.toString(), 'white', 65, gameState.canvasWidth/2, gameState.canvasHeight/2)
ctx.globalCompositeOperation="screen";
ctx.globalAlpha=1/remaining
drawText(ctx, remaining.toString(), 'white', 60, gameState.canvasWidth/2, gameState.canvasHeight/2)
}
}
ctx.globalAlpha=1
startWork("render:askForWakeLock");
askForWakeLock(gameState);

1
src/types.d.ts vendored
View file

@ -283,6 +283,7 @@ export type GameState = {
rerolls: number;
creative: boolean;
startParams: RunParams;
startCountDown:number;
};
export type RunParams = {