Coding Challenge #32.2: Agar.io - Part 2 (Networking with Socket.IO and Node.js)
In this multi-part coding challenge, I create a clone of the multiplayer online game Agar.io with JavaScript, node.js and websockets. Code: https://thecodingtrain.com/challenges/32-agario
πΉοΈ p5.js Web Editor Sketch: https://editor.p5js.org/codingtrain/sketches/J3BZeLP02
Other Parts of this Challenge:
πΊ Agar.io - Part 1 (Basic Game Mechanics): https://youtu.be/JXuxYMGe4KI
π₯ Previous video: https://youtu.be/cXgA1d_E-jY?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Next video: https://youtu.be/flQgnCUxHlw?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
π Agar.io on Wikipedia: https://en.wikipedia.org/wiki/Agar.io
π Agar.io: http://agar.io
π Node.js: https://nodejs.org/en/
π Socket.io: http://socket.io/
Videos:
π Collaborative p5.js Sketches Channel: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6b36TzJidYfIYwTFEq3K5qH
Livestream Archive:
π΄ Livestream #55: https://youtu.be/eOii4P7WYbY
π΄ Livestream #58: https://youtu.be/_cDPN2Ief6Q
Related Coding Challenges:
π #36 Blobby!: https://youtu.be/rX5p-QRP6R4
π #69 Evolutionary Steering Behaviors: https://youtu.be/flxOkx0yLrY
Timestamps:
0:00 Introduce the coding challenge
0:23 Mention the previous coding challenge 'Agar.io - Part 1'
0:52 Mention tutorial on node.js and web sockets
1:22 Sketch client-server communication
3:00 Set up a node server
4:35 Examine server code
5:00 Examine client code
5:10 Add a web socket
5:42 Reference the socket library
6:42 Update agar.io code
7:42 Consider server code
8:34 Create a blob constructor
9:11 Associate the connection `id` to the blob
10:40 Create a blob once a connection receives a `start` message
11:36 Consider client code
11:51 Send a `start` message to the server
13:08 Test client-server communication
14:00 Send the correct position
14:42 Use a random location and size
15:55 Update blob location
16:20 Send an `update` message
16:53 Handle the `update` message
17:30 Find blob by `id`
18:25 Update blob location
19:18 Test update logic
19:59 Test multiple connections
21:53 Constrain blob movement
23:40 Summarize the coding challenge
25:11 Broadcast a message from the server
27:33 Broadcast the array of blobs
28:41 Display the blobs on the client
30:56 Restart server
31:30 Debug drawing logic
31:51 Draw the `id` for each blob
33:20 Avoid drawing the same blob
33:57 Consider the client's own `id`
36:00 Draw blobs with a different `id`
37:55 Test game with two clients
41:20 Increase update frequency
42:30 Conclude the coding challenge
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: http://thecodingtrain.com/
πΎ Share Your Creation! https://thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: https://github.com/CodingTrain/Suggestion-Box
π‘ GitHub: https://github.com/CodingTrain
π¬ Discord: https://discord.gg/hPuGy2g
π Membership: http://youtube.com/thecodingtrain/join
π Store: https://standard.tv/codingtrain
ποΈ Twitter: https://twitter.com/thecodingtrain
πΈ Instagram: https://www.instagram.com/the.coding.train/
π₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: https://p5js.org
π p5.js Web Editor: https://editor.p5js.org/
π Processing: https://processing.org
π Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/thecodingtrain.com/issues/new
#agario #websockets #javascript #nodejs
Other Videos By The Coding Train
Other Statistics
Agar.io Statistics For The Coding Train
At present, The Coding Train has 506,761 views spread across 4 videos for Agar.io, and about 5 hours worth of Agar.io videos were uploaded to his channel. This is less than 0.50% of the total video content that The Coding Train has uploaded to YouTube.