Example
const root = document.querySelector('#plinko-root');
const game = new PlinkoGame(root, {
binLabels: [
'x666',
'x66',
'x11',
'x4',
'x2',
'x0.50',
'x0.20',
'x0.50',
'x2',
'x4',
'x11',
'x66',
'x666',
],
binColors: [
'#00ff5a',
'#7dff57',
'#c9ff4b',
'#ffe645',
'#ffb53d',
'#ff7a33',
'#ff2a2a',
'#ff7a33',
'#ffb53d',
'#ffe645',
'#c9ff4b',
'#7dff57',
'#00ff5a',
],
visual: {
ballColor: '#00ff5a',
pegColor: '#e5e7eb',
binCornerRadius: null,
label: {
fontSize: 20,
fontWeight: 800,
color: '#020617',
},
pegPulse: {
enabled: true,
duration: 320,
ringOffset: 0,
spread: 12,
lineWidth: 3,
alpha: 0.6,
maxPulses: 50,
},
pulse: {
enabled: true,
duration: 500,
lift: 8,
},
ballTrail: {
enabled: true,
duration: 500,
maxPoints: 80,
spacing: 4,
minWidth: 2,
maxWidth: null,
alpha: 0.35,
color: null,
fade: true,
},
},
audio: {
masterVolume: 1,
collision: {
enabled: true,
path: '/audio/plinko-collision.mp3',
volume: 1,
},
landing: {
enabled: true,
path: '/audio/plinko-bin-landing.mp3',
volume: 1,
},
},
onReadyChange: (ready) => {
console.log('ready', ready);
},
onDrop: ({ dropId, targetBinIndex }) => {
console.log('drop', dropId, targetBinIndex);
},
onResult: ({ binIndex, label, targetBinIndex }) => {
console.log('result', label, binIndex, targetBinIndex);
},
onError: (error) => {
console.warn('[plinko] error', error);
},
});
game.dropBall(6);