add: loud buzzer
This commit is contained in:
parent
630f59055a
commit
8d6272c85d
@ -27,6 +27,7 @@ class MatchMaking
|
||||
return null;
|
||||
|
||||
this.gamemode = gamemode
|
||||
|
||||
let url = `${window.location.protocol[4] === 's' ? 'wss' : 'ws'}://${window.location.host}/ws/matchmaking/${mode}`;
|
||||
|
||||
this._socket = new WebSocket(url);
|
||||
|
@ -19,16 +19,36 @@ class TicTacToe
|
||||
|
||||
init()
|
||||
{
|
||||
this.canvas.addEventListener("mousedown", (event) => { this.onClick(event) }, false);
|
||||
this.canvas.addEventListener("mousedown", (event, morpion = this) => this.onClick(event, morpion));
|
||||
}
|
||||
|
||||
uninit()
|
||||
{
|
||||
this.canvas.removeEventListener("mousedown", this.onClick, false);
|
||||
this.canvas.addEventListener("mousedown", (event, morpion = this) => this.onClick(event, morpion));
|
||||
}
|
||||
|
||||
onClick(event)
|
||||
onClick(event, morpion)
|
||||
{
|
||||
let x = event.offsetX;
|
||||
let y = event.offsetY;
|
||||
let targetMorpion, targetCase;
|
||||
|
||||
function checkCase(targetMorpion, targetCase)
|
||||
{
|
||||
console.log("TargetMorpion :" + targetMorpion + " targetCase :" + targetCase);
|
||||
return (morpion.game[targetMorpion][targetCase] == -1);
|
||||
}
|
||||
|
||||
function incorrectCase()
|
||||
{
|
||||
console.log("bozo");
|
||||
}
|
||||
|
||||
function sendCase(targetMorpion, targetCase)
|
||||
{
|
||||
// send to backend (stp camille code bien)
|
||||
}
|
||||
|
||||
function findPlace(x, morpion)
|
||||
{
|
||||
if (x <= morpion.gap || x >= morpion.gap + morpion.rectsize * 9)
|
||||
@ -53,22 +73,15 @@ class TicTacToe
|
||||
return -1;
|
||||
}
|
||||
|
||||
let x = event.offsetX;
|
||||
let y = event.offsetY;
|
||||
let targetMorpion, targetCase;
|
||||
|
||||
targetMorpion = findPlace(x, this) + findPlace(y, this) * 3;
|
||||
if (findPlace(x, this) < 0 || findPlace(y, this) < 0)
|
||||
return -1;
|
||||
targetCase = findSquare(x, this.rectsize * 3 * findPlace(x, this) + this.gap, this) + findSquare(y, this.rectsize * 3 * findPlace(y, this) + this.gap, this) * 3;
|
||||
console.log("TargetMorpion :" + targetMorpion + " targetCase :" + targetCase);
|
||||
|
||||
|
||||
// if (sendCase(targetCase, targetMorpion)) // si la case est disponible
|
||||
// putCase(targetCase, targetMorpion); // print the case
|
||||
// else
|
||||
// return ;
|
||||
|
||||
if (checkCase(targetMorpion, targetCase))
|
||||
sendCase(targetMorpion, targetCase);
|
||||
else
|
||||
incorrectCase();
|
||||
}
|
||||
|
||||
DrawSuperMorpion()
|
||||
|
BIN
frontend/static/js/api/game/sounds/incorrectbuzzer.mp3
Normal file
BIN
frontend/static/js/api/game/sounds/incorrectbuzzer.mp3
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user