Share your repls and programming experiences

← Back to all posts
Multiplayer cursors!
MarcusWeinberger (667)

Interact with visitors as you watch their cursor move around the page! Now with visual feedback for clicks!

How it works

The server code is very small, almost all the work is done client-side. The server just allows clients to communicate with each other. One thing that the server does is check for disconnected users, and instruct clients to remove their cursor from screen.

The client constantly updates the server with its current cursor coordinates (nice alliteration) and notifies the server for each click.

Check it out

Big credits to @rafrafraf , we worked on this together. More to come!

ColeBosman (12)

yooooooo this is lit

MarcusWeinberger (667)

@ColeBosman Glad you like it :) i saw your cursor in there lol

realTronsi (901)

great start, the server is quite delayed but this reminds me of

fuzzyastrocat (1504)

@realTronsi Same, it'd be cool to make this in that there would be some goal you have to collaborate to achieve.

Nettakrim (392)

you can type stuff into the console

socket.emit('update',{'user':"hello",'x':0,'y':0}) this will spawn in a cursor at that location, if a cursor with that name already exists it will move it
socket.emit('click',{'user':"hello",'x':150,'y':150}) this will make the little ripple at that location, the color of it is based on the first letter of the user
this will send a message to the console as name in user

SixBeeps (4738)

@BrutalBucket That'll cause compatibility and security issues, better to just validate requests on the server.

RahulChoubey1 (130)

What does the lonely input box do?

ChezTacoz (344)

Love it!!! Just 2 things that I think would make it even better:

  1. If you could choose the color of your cursor
  2. If you could talk to others without having to change you username

Other then that great program!!!

MarcusWeinberger (667)

@ChezTacoz a chatroom is currently in the works :)

ChezTacoz (344)

@MarcusWeinberger that's good I'm super excited!!!

rafrafraf (1365)

@ChezTacoz ill definitely add choosing your own color thanks for the suggestion

CodingRedpanda (162)

I never did think that cursors were cool, until this happened! What the flip!

LoganB2 (6)

wth, I could never do this

Gabby8C0des8 (26)

pretty damn cool😆

FloCal35 (351)

This is awesome lol


On chrome i get this error:
Uncaught TypeError: Cannot read property 'length' of undefined
at updateMouse ((index):123)
at HTMLDivElement.onmousemove ((index):69)

Bookie0 (5645)

Hehe nice job. Try making different visual effects for the mouse clicks ;)

rafrafraf (1365)

@Bookie0 thats a really good idea, ill work on that today 👍

ZainJ13 (2)

I've actually never seen anything like this on This is crazy! Nice job! @MarcusWeinberger


XD bruh, ur job title in email is sooo immature, lol. probably took u 10000 hours to come up with that XD

Glare (235)

I'm happy I found this. This is sweet!

Blackout4344 (36)

Some people were swearing at me :(

HackermonDev (1989)

I found a bug! If you try an XSS attack, it won't work but it will create another cursor and you would be controlling two cursors. (only doing XSS attack to test)

Leroy01010 (414)

cool send me the code!(jk) @PDanielY

MarcusWeinberger (667)

@PDanielY yeah, xss was previously working and this was just a quick fix i implemented, i'll need to fix that

EpicRaisin (245)

This is so cool! I'd love to see a dragging indicator, like maybe a fading trail showing where you've dragged at.
EDIT: also, what if there was a tag version, so you click someone then theyre it

rafrafraf (1365)

@EpicRaisin we may work on these soon thanks for the suggestions 👍

brogen (40)

maybe have to get to like 100 clicks first.

RahulChoubey1 (130)

Don't add a cancel option if canceling does nothing

RahulChoubey1 (130)

@MarcusWeinberger The popup has a cancel button which just loops back

CodingRedpanda (162)

@RahulChoubey1 the cancel button is default for javascript prompt()s.

RahulChoubey1 (130)

@ridark then why the restart? Every time I enter this to read a comment, it forces me to make a username.

CodingRedpanda (162)

@RahulChoubey1 because when you enter the post the repl turns on and the javascript acts and prompt()'s your username

RahulChoubey1 (130)

@ridark Can't there at least be an option to not enter a username?