let socket = io.connect(':30000?sketch=1016696');
createCanvas(windowWidth, windowHeight);
myName = prompt('What\'s your name?');
myColor = color(round(random(0, 255)), round(random(0, 255)), round(random(0, 255)));
me = new Person(random(100, windowWidth - 100), random(100, windowHeight - 100), formatText(myName), myColor);
dummy = new Person(100, 100, 'Dummy', color(0));
socket.on('update', updateUsers);
socket.on('chat', updateChat);
textAlign(CENTER, CENTER);
text(user.name, user.x, user.y - 50);
ellipse(user.x, user.y, 70, 70);
if(chat instanceof Chat) {
socket.emit('chat', chat);
socket.emit('update', me);
rect(200, windowHeight - 150, 300, 200, 5);
text('Send Chat', 200, windowHeight - 150);
chats = chats.filter((that) => {
return that.x < windowWidth && that.x > 0 && that.y < windowHeight && that.y > 0;
function mousePressed() {
if(mouseX > 50 && mouseX < 350 && mouseY < windowHeight - 50 && mouseY > windowHeight - 250) {
function updateUsers(user) {
let chat = users.filter(d => d.name == user.name);
chat[0].color = user.color;
function updateChat(chat) {
let message = chats.filter(d => d.sender == chat.sender);
if(message.length == 0) {
message[0].message = chat.message;
if(keyCode == UP_ARROW) {
} else if(keyCode == DOWN_ARROW) {
} else if(keyCode == LEFT_ARROW) {
} else if(keyCode == RIGHT_ARROW) {