Share your repls and programming experiences

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

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!

Commentshotnewtop
ColeBosman (11)

yooooooo this is lit

MarcusWeinberger (585)

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

Nettakrim (388)

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
socket.emit('msg',{'user':"hello",'text':"message"})
this will send a message to the console as name in user

SixBeeps (3064)

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

RahulChoubey1 (23)

What does the lonely input box do?

ChezTacoz (342)

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 (585)

@ChezTacoz a chatroom is currently in the works :)

ChezTacoz (342)

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

rafrafraf (237)

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

realTronsi (250)

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

fuzzyastrocat (769)

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

[deleted]

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

ridark (91)

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

LoganB2 (4)

wth, I could never do this

Gabby8C0des8 (24)

pretty damn cool😆

FloCal35 (132)

This is awesome lol

HENRYMARTIN4 (344)

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

Bookie0 (4009)

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

rafrafraf (237)

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

ZainJ13 (2)

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

Glare (229)

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

Blackout4344 (30)

Some people were swearing at me :(

EpicRaisin (11)

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 (237)

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

brogen (42)

maybe have to get to like 100 clicks first.

RahulChoubey1 (23)

Don't add a cancel option if canceling does nothing

RahulChoubey1 (23)

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

ridark (91)

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

RahulChoubey1 (23)

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

ridark (91)

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

RahulChoubey1 (23)

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

Kookiez (129)

wow this is so cool