Show HN: Snaketron, online multiplayer Snake
snaketron.com
snaketron.com
The client should only be able to send the direction it's turning and on which turn, and that's it. The server should allow for some slack in the turn numbers, but not much.
I encountered some bugs where there was a guy who couldn't lose. He just kept going straight and when he ran into me he didn't die. Maybe someone cheating by editing the JS?
Also, I noticed some glitches where other players' snakes had a really high velocity. Or was that a power up that I didn't get?
Tangent: Does anyone notice CRAZY GC pauses on Firefox, or something that appears every 5 seconds or so? It makes the game almost unplayable on Firefox. Switched to Chrome to play it.
A couple of questions: I thought that if one snake ran into another, it would end the game but there were a couple of times where they just passed thru each other. Was this a bug?
Also, there were a couple of times when either I or my opponent ran into the other, and it ended in a tie. Shouldn't that be a win for the other player?
I've also had it tell me "You won. :(" which is incorrect. :)
Edit: the Github badge at the top can get in the way. And there could be a check if you've disconnected. And it doesn't remember me if I reload.
All space bars and arrows while playing the game should fix that.
The run down is this. server.js is a long running script and it only has a few global vars like games and playerQueue. These belong to the application as a whole. They're basically data structures that hold everything that's happening. Which games are being played, which players are waiting, and so on. The main stuff happens with socket.io in the io.sockets.on('connection' ... The paramter 'socket' in this code refers to the connection to a single player so if my server logic says that this player just won the game, I would say socket.emit('won-game') or in my situation I emit a 'gameover' message with some data specifying which username just won.
There's a lot more to it and I plan on getting to commenting the code better but that should point you in the right direction if you want to analyze the code.
Btw, where do you host this app?
Anyway though, I do think it's well done, and open source too, so no real complaints.
One other little problem I noticed (on FF13) is that if I accidentally held the down or up keys for too long, my browser would scroll down the page.
Kind of silly, since they'd obviously get bored quickly, but still a problem.
I'm curious if you did by any chance see my take on multiplayer snake? (From here or the tigsource forums, maybe? It's playable at http://bfilmhelden.de:8080/ less polished tough. Made some different choices. (E.g. clients can only send commands, and also send always the full game state.)
Last game my opponents snake ran into me and I could tell that he was then done playing because his snake kept going in a straight line over and over. About a minute later it finally said I won.
Just a heads up.
Or .. were there still snacks popping up after he ran into you? If not, it's possible that the server restarted when that happened due to some exception so you just ended up playing solo with no server connection.
Fantastic game though, so addictive... the running score, and win ratio are great. It would be cool if you could see your opponent's win ratio or a rank of some sort too? Perhaps when you're counting down for the game to start?
Small bug: over 10.0 W/L and it stopped showing up in the leaderboards: http://i.imgur.com/NChEp.png
Once I lost a 2nd game it appeared again.
The meta competition is an addiction +1 powerup.
My personal recommendation is some catchy techno tune as music. Heart pumping sort of music that gets you into the zone.
EDIT: It's the extensions' fault, just to be clear. Also, I'm amazed by the addictive nature of this simple game!
Would be cool to have maybe 3 rounds vs the same opponent and a chat window, so the competition can heat up a little.
Also, I hope passwords aren't being stored in clear text :)
Great fun though...collisions of snakes are buggy, but other than that it's really a good time.