Merge branch 'main' into multiplayer

This commit is contained in:
H4CK3R-01
2021-06-14 12:08:02 +02:00
committed by GitHub
17 changed files with 5223 additions and 562 deletions

View File

@@ -9,7 +9,7 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
this.text = text;
this.status = status;
this.button_is_answer = button_is_answer;
this.click = click;
this.pointerdown = click;
this.selected = false;
let _this = this;
@@ -20,17 +20,17 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
this.graphics.beginFill(color);
this.graphics.drawRect(this.x, this.y, this.width, this.height);
this.graphics.endFill();
}
};
this.selectButton = function () {
this.selected = true;
this.changeButtonColor(select_color);
}
};
this.unSelectButton = function () {
this.selected = false;
this.changeButtonColor(default_color);
}
};
this.getButton = function () {
const style = new PIXI.TextStyle({
@@ -55,7 +55,7 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
this.graphics.interactive = true;
this.graphics.buttonMode = true;
this.graphics.defaultCursor = 'pointer';
this.graphics.on('click', function () {
this.graphics.on('pointerdown', function () {
click();
});
this.graphics.on('mouseover', function () {
@@ -67,5 +67,5 @@ function Button(default_color, hover_color, select_color, width, height, x, y, t
if (!_this.selected) _this.changeButtonColor(_this.default_color);
});
return this.graphics;
}
};
}

View File

@@ -6,12 +6,12 @@ function Sprite(x, y) {
this.getSprite = function () {
this.setSize(this.sprite, sprite_size);
return this.sprite;
}
};
this.setSize = function (sprite, size) {
sprite.x = this.coord_x * size - size * 0.2;
sprite.y = this.coord_y * size - size * 0.2;
sprite.width = size * 1.5;
sprite.height = size * 1.5;
}
};
}

View File

@@ -2,7 +2,9 @@ let socket;
let connected = false;
function start_chat() {
socket = io();
socket = io("/", {
closeOnBeforeunload: false
});
socket.on('login', function () {
connected = true;
@@ -43,6 +45,7 @@ function addLogMessage(message) {
li.innerText = message;
document.getElementById("messages_received").appendChild(li);
document.getElementById("messages_received").scrollTop = document.getElementById("messages_received").scrollHeight;
}
function addChatMessage(data) {
@@ -65,4 +68,12 @@ function addChatMessage(data) {
messageDiv.appendChild(messageBody);
document.getElementById('messages_received').append(messageDiv);
}
document.getElementById("messages_received").scrollTop = document.getElementById("messages_received").scrollHeight;
}
document.getElementById('message_input').onkeydown = function (e) {
if (e.key === "Enter") {
sendMessage();
e.preventDefault();
}
};

View File

@@ -64,7 +64,7 @@ let sprites = [
function start_game() {
app = new PIXI.Application({
autoResize: true,
resolution: devicePixelRatio,
resolution: 1,
backgroundAlpha: 0,
width: max_size / game_board_size,
height: max_size / game_board_size
@@ -126,7 +126,7 @@ function start_game() {
dice.interactive = true;
dice.buttonMode = true;
dice.defaultCursor = 'pointer';
dice.on('click', function () {
dice.on('pointerdown', function () {
if (!diced) {
socket.emit('roll dice');
}
@@ -185,7 +185,7 @@ function generate_card_stack(sprite, x, y, onclick) {
sprite.interactive = true;
sprite.buttonMode = true;
sprite.defaultCursor = 'pointer';
sprite.on('click', onclick);
sprite.on('pointerdown', onclick);
return sprite;
}