improve chat
This commit is contained in:
parent
2ae3d43354
commit
61ae57a850
14 changed files with 306 additions and 33 deletions
|
@ -35,6 +35,15 @@ body {
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
#gui #chat b {
|
||||
font-weight: 100;
|
||||
color: #8af;
|
||||
}
|
||||
|
||||
#gui #chat span.server {
|
||||
color: #68c;
|
||||
}
|
||||
|
||||
#gui #chat input {
|
||||
font-family: inherit;
|
||||
font-size: 16px;
|
||||
|
|
|
@ -15,20 +15,28 @@ GUI.prototype.Chat = class {
|
|||
addMessage(messageData) {
|
||||
let message = {
|
||||
type: messageData.type,
|
||||
player: messageData.player,
|
||||
source: messageData.source || '?',
|
||||
text: messageData.message,
|
||||
createTime: Date.now()
|
||||
};
|
||||
|
||||
let span = this.gui.createElement(this.messageElement, 'span', {
|
||||
html: message.text
|
||||
});
|
||||
let span;
|
||||
|
||||
if (message.type == 'server') {
|
||||
span = this.gui.createElement(this.messageElement, 'span', {
|
||||
html: `${message.text}`
|
||||
});
|
||||
span.classList.add('server');
|
||||
} else {
|
||||
span = this.gui.createElement(this.messageElement, 'span', {
|
||||
html: `<${message.source.bold()}> ${message.text}`
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
this.messages.push(message);
|
||||
|
||||
setTimeout(_ => {
|
||||
this.messageElement.removeChild(span);
|
||||
this.messages.shift();
|
||||
//this.messageElement.removeChild(span);
|
||||
}, 15000);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,15 @@ class GUI {
|
|||
return result.length == 1 ? result[0] : result;
|
||||
}
|
||||
|
||||
format() {
|
||||
let args = Array.from(arguments);
|
||||
let text = args.shift();
|
||||
let element = args.shift();
|
||||
let string = `<${element} class="${args.join(' ')}">`;
|
||||
string += `${text}</${element}>`;
|
||||
return string;
|
||||
}
|
||||
|
||||
tick() {
|
||||
this.chat.tick();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class Renderer {
|
|||
this.effects = new Set();
|
||||
|
||||
pallet.fillScreen();
|
||||
window.addEventListener('resize', pallet.fillScreen);
|
||||
window.addEventListener('resize', _ => pallet.fillScreen(1000, 600));
|
||||
}
|
||||
|
||||
render(state) {
|
||||
|
|
|
@ -28,7 +28,7 @@ class Physics {
|
|||
bodyDef.angularVelocity = 0;
|
||||
bodyDef.bullet = body.type == 'missile';
|
||||
bodyDef.linearDamping = body.bodyType == 'asteroid' ? 0.003 : 0.01;
|
||||
bodyDef.angularDamping = body.bodyType == 'asteroid' ? 0.003 : 0.04;
|
||||
bodyDef.angularDamping = body.bodyType == 'asteroid' ? 0.003 : 0.06;
|
||||
bodyDef.type = body.bodyType == 'structure' ?
|
||||
b2Body.b2_staticBody : b2Body.b2_dynamicBody;
|
||||
bodyDef.allowSleep = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue