makefuture / games / accept-the-cookie / game / scenes / ConsentScene.js
146 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { detectAdblock } from '../systems/adblock.js?v=20260427c';
import { showConsentModal } from '../systems/consent.js?v=20260427c';
import { collectFingerprint } from '../systems/fingerprint.js?v=20260427c';
import { collectGeolocation } from '../systems/geolocation.js?v=20260427c';

export class ConsentScene extends Phaser.Scene {
    constructor() {
        super('ConsentScene');
    }

    init(data) {
        this.session = data.session;
    }

    create() {
        this.cameras.main.setBackgroundColor(0x111111);
        this.add.text(this.scale.width / 2, this.scale.height / 2, 'ACCEPT THE COOKIE', {
            fontFamily: 'system-ui, sans-serif',
            fontSize: `${Math.max(26, Math.min(68, this.scale.width * 0.07))}px`,
            color: '#ffffff',
            fontStyle: '800',
        }).setOrigin(0.5);
        this.add.text(this.scale.width / 2, this.scale.height / 2 + 58, 'A totally normal website experience', {
            fontFamily: 'system-ui, sans-serif',
            fontSize: '13px',
            color: '#777777',
            letterSpacing: 2,
        }).setOrigin(0.5);
        this.runConsentFlow();
    }

    async runConsentFlow() {
        await showConsentModal(this.session);
        this.showStatus('Preparing your personalized experience...');
        await collectFingerprint(this.session);
        detectAdblock(this.session);
        await collectGeolocation(this.session);
        this.scene.start('ArcadeScene', { session: this.session });
    }

    showStatus(message) {
        this.add.rectangle(this.scale.width / 2, this.scale.height - 84, Math.min(520, this.scale.width - 40), 46, 0xffffff, 0.08);
        this.add.text(this.scale.width / 2, this.scale.height - 84, message, {
            fontFamily: 'system-ui, sans-serif',
            fontSize: '13px',
            color: '#ffffff',
        }).setOrigin(0.5);
    }
}

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/makefuture.git