Live data from Hacker News

Show HN: Snaketron, online multiplayer Snake

snaketron.com

31–40 of 56 posts

Re: Show HN: Snaketron, online multiplayer Snake

#31

This is very nicely done, thanks for making it open-source - I'm learning node to work on a game idea I've had for a long time. Could someone explain the basic idea of server.js and some of the stuff in public? It's a little overwhelming.

Yea definitely, I wanted to comment this better but I was just too eager to release it hah.

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.

Re: Show HN: Snaketron, online multiplayer Snake

#32

As more people keep playing I've noticed it's starting to glitch. 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.

Gotcha. I haven't experienced that yet but it may be resulting from all the traffic I'm getting right now.

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.

Re: Show HN: Snaketron, online multiplayer Snake

#33

Cool game but quite buggy. Sometimes a snake went through me, another time the opponent rammed into me and it was a draw. If we can have 3D shooters online without these problems, I would think a snake game would be possible too ;D Anyway though, I do think it's well done, and open source too, so no real complaints.

Thanks :) I think the issue is that some people are playing with browsers that don't support web sockets, so even if you support them, their connection affects the synchronization between you two. I should probably start doing some feature detection for websockets

Re: Show HN: Snaketron, online multiplayer Snake

#34
My biggest problem with this is I've gotten two opponents which didn't try to grow, just kept going in circles. They were pretty much guaranteed to win, since I eventually hit myself. Even if I hit them, it was just a draw.

Kind of silly, since they'd obviously get bored quickly, but still a problem.

Re: Show HN: Snaketron, online multiplayer Snake

#38

My biggest problem with this is I've gotten two opponents which didn't try to grow, just kept going in circles. They were pretty much guaranteed to win, since I eventually hit myself. Even if I hit them, it was just a draw. Kind of silly, since they'd obviously get bored quickly, but still a problem.

Hey man, that was my strategy a few times.. seems like a legit way to play I think.
Post reply on HN