Programming a multiplayer game from scratch in 7 DAYS
Vložit
- čas přidán 31. 05. 2024
- Grab a free 30 day trial and 20% off an annual plan: brilliant.org/jdh/
time for some wizardry
PATREON: / jdah
TWITTER: / jdah__
** itch link coming soon ! **
BASIC NETWORK DEMO: gist.github.com/jdah/08eb80c7...
MACRO WIZARDRY: gist.github.com/jdah/1ae0048f...
THINSG MENTIONED IN THE VIDEO
* networking articles: www.gabrielgambetta.com/entit...
* enter the gungeon levels: www.boristhebrave.com/2019/07...
GITHUB: github.com/jdah
EDITOR: NeoVim
CONFIGS: github.com/jdah/dotfiles
THEME: gruvbox
RESOURCES:
* OpenGL: learnopengl.com
OTHER VIDEOS:
Minecraft in 48 hours - • Making Minecraft from ...
Building my own graphics card - • I built my own graphic...
Building a DOOM-style rendering engine - • Programming a first pe...
Tetris OS - • I made an entire OS th...
0:00 Intro
0:20 One week
16:00 Extras
17:11 Outro & Thanks - Věda a technologie
Take a shot every time jdh starts a game from scratch
quick way to get alcohol poisoning
@@jdh Hard mode: When he implements shit on his own and trying to reinvent the wheel rather then using a robust library
@@siteking4289 So basically continue drinking constantly?
You're dead.
No big surprise.
@@siteking4289 Tbh I can kinda respect his determination.
Honestly, the idea of enemies being able to light their loot drops on fire before they die is really funny ngl
I feel like there could be reasoning behind loot drops being set on fire/carrying whatever status effects the enemy had before dying. Like the spell affects the enemy *and* whatever it's carrying too
It could be a decent balancing technique
its a feature. not a bug :)
Dude. You make it look reasonable and almost easy implementing things from scratch in C. That's a feat in and of itself.
After he added serialization to C++ I’m convinced he can do anything.
Writing network code without libraries looks incredibly complex. Love every devlog! I really admire the dedication to the bit with using no libraries even when it's an active hinderance lol
active hinderance or learning experience? you decide!
Both@@jdh
It's not incredibly complex, and he is using a "library," i.e. the networking functionality provided by the operating system. It is really as simple as saying send this buffer to that address using this protocol.
@@flaviog141 Eh, I duno if invoking POSIX syscalls directly really counts as "a library"... I suppose it technically counts, as it is part of the C standard library, and it's not like directly bit-banging raw network packets at the NIC over the PCI bus, but still...
And building something useful on top of raw buffers may not the terribly difficult (especially with some experience under your belt), but it's not exactly trivial either, especially in just a day or two.
@@SolarShadoit's not part of the C standard library
Don't feel bad about starting a project, getting so far that it's almost complete, and then getting sidetracked and starting something new. It happens to the best of us.
this guy is the best of us
im an artist and feel so called out rn x)
It says in the vid for a split second he is still working on the cos but has nothing interesting to show rn
Artists be the exact same 😂😂
I think the flaming coin bug should definitely stay!
Exactly - my first thought when I saw that part was "Is this a bug, or a feature?"
9:31 Wtf, don't just say you casually made the entire UI look that good in half an afternoon! This is incredible, I can barely make so much as a menu that works, let alone something this pretty.
I literally said "no you didn't" seconds after that time stamp lol
@@buildgameswithjon7641Samee
I absolutely love your approach to game dev. Whenever i feel burned out from working on a project. I just watch your videos for motivation. Splendid work as always ❤
The things you did in a week would've taken me at least a couple months. Your talent and work ethic are amazing
i never comment on videos but holy moly man ! you covered a good chunk of topics from 2 courses which i had this semester in a 1 week, gracefully, from scratch and made it look easy !! i know how much i struggled when understanding packets (we wrote a program for processing, NAT translation and portforwarding) but seeing you do it from 0, make everything multithreaded and not drop packets from host to player is insane, well done :)
I was just checking your channel yesterday to see if you'd uploaded. I'm very excited to watch this one
it is so impressive how you manage to pull off programming a working multiplayer game in such a short time!! I really admire your work!!:)
This is awesome! I've been watching since the Minicraft remake, and your stuff just gets better and better!
Your FPS game is looking amazing, and I actually really love the main menu for this one lol
1 week? Good lord that's very impressive good job man
Your videos are so well done, I've watched some of them more than multiple times, and now your editing has improved too! Really great content, you inspired me in many different ways and I hope you'll continue to do so for everyone that gets the chance to know you.
wake up hun, hes back.
He's about to cook for the whole family!
I'll get the broom...
The speed of light is unknown in 1 direction, at 7:00 the diagram shows that it takes 100ms to travel to the server and 100ms back to client. Theoretically it is equally as possible that it could take 199ms to send to the server and 1ms to send it back, or any numbers that add to 200ms. Just think it’s kinda interesting and wanted to share
Ok yes but that’s a theory. Occam’s razer.
@@ezrakornfeld8436 Yes, it’s only a theory, but even Einstein says that the speed of light and clock synchronization is only defined by convention, rather than a measurement. I agree that the most simple explanation to our understanding would be for the speed to be the same, but it’s interesting to me that this principal that is base to our understanding of the universe isn’t fully understood.
for sure! my example was definitely a bit contrived
The speed of light doesn't really matter, just the speed of packet transmission. Over the Internet it's very likely that the packets each way are taking different paths.
@@eDoc2020 The time it takes for a packet to reach a server from a client is unknowable. No matter the path it takes or the distance it travels, it can only be assumed or measured when the server sends a packet back to the client.
It’s not really important to this video though
The concept of sending the player position directly to the server is also how Minecraft handles multiplayer. The way they (try to) prevent hacking is by only checking a few edge cases on the server side to prevent obvious cheats, like if the distance between the old and new position is too big, you get sent back, or if your vertical speed is 0 for too long even though you're not standing on a block, you get kicked out.
I was just hopin for a vid from u soon, great timing
You are a great inspiration to me as someone learning to code. Great vid and congrats on that sponsorship
I honestly don't know why, but I love watching every video you do. It scratches some part of my brain that wants to do stuff like this but that I don't have time to do because of working and having too many other things I want to do. It does give me some inspiration to actually work on the programming projects that I am actually working on though.
Finally jdh finishing a game.
Entertaining video as always, hope you make more soon!
One of the few places I can come to see games written at this low level, thank you for your content and hard work!!!
Im on my last term of my second year at a master's programme in computer and information engineering and this video was an absolute blast. I was surprised with how much I understood of all the really techy/nerdy stuff, and it was just really cool to see how everything was implemented.
I would love to see more of the engine programming and implementation though.
FINALLY! been waiting for another video forever!
This is insane, you'r an inspiration to me and i can only hope to come close to this level of expertise!
The monster loot catching on fire is some real dwarf fortress material. Great video and project as always!
great video as always, to show input lag, assuming you are using OBS (and not a screen recorder you made from scratch), you can use the same plugin that streamers use to show their keypresses. either visualy or by text.
Congratulations, and thanks for the video, it’s amazing
Small game side projects are very fun. Great video!
I'm in awe after discovering this channel. I'm taking cs in university right now, and I'm just curious how and where you learned all of this stuff. It absolutely baffles me. I would love to see a video of your journey through coding, math, development, etc. Or I guess you could just reply to my comment lol
Nice work! This looks really fun :P
love your stuff, man, even if i have no clue what you're doing, lol
you mentioned the fps game, and it looked cool in the last devlog, so im curious on how it's going
The game actually looks fun, and this video was really instructional. Thanks a lot jdh for your amazing content!👍
I helped with a macro to enable authoritative servers for an RPC library written in Nim. All the actual netcode works on a custom implementation of UDP that keeps the packets in order and resends dropped packets. It works pretty damn well.
It’s actually insane; the macro creates all the boilerplate on the client and server so that a client can call server functions and the server can call client functions. The dude who wrote the base library is a very smart dude, I learned a ton
Your skills are amazing, loved it
please continue the last video's project!! it looks so damn good and fun
You need synergy spells where one wizard does a fire spell and the second wizard does an aspect - these then combine to attack an opponent.
You could have scissor-paper-stone on fire-air-water and pulse-quick-slow aspect. This requires you to know the enemy and coordinate on spells.
Or one casts a region spell that the other casts into. You could have probe spells that test the features of the enemy.
When two enemies are close they enhance or disable each other.
You could have bosses that shift aspects over time or in response to particular spells.
Powerups to shift aspect/element.
You could also have a-b-c combo spells where you cast a, partner casts b and the you cast c - knowing that a-b-c does extra damage/freeze to enemy.
This comment needs more likes 👍
Looks really cool, great job!
This is impresive. I am working a lot currently in SDL, but need more time for it. For network stuff i would try it with a common lib.
Love your vids dude! Awesome stuff
Someday you should consider a tutorial on how you set up your neovim and build with C… 🙃
Seeing stuff like this inspires me to be a better developer. I love C but only ever just do web backend for work. I'd love to get more into things like this
Good job. I had to write a paper on this "Fast Action Multiplayer in P2P Networking Over Mobile Connections" or something. A bit of reliability over udp (tip: bitfield of acks n packet count and back), sub message resending with classifications (lossy, priority, etc.), host change resyncing, hole punching, matchmaking, relay fallbacks, some spline extrapolation (first network tracking entity movement as paths over keyframes synced by time then again in opengl renderer thread), exponentially smoothed average on the latency, fun times xD
sounds interesting! Though I didn't mention it, I used TCP for this in the interest of not wanting to handle all of those things but if this networking backend gets used elsewhere (maybe in a fast paced retro FPS who knows) then I'll definitely want to make the switch over to UDP and handling the reliability issue myself. Do you have any good links to papers/resources/etc.?
Building from scratch like this honestly feels more sane than using libraries. It really doesn’t have to get any more complex than using send() and recv().
YAY i just got re-obsessed with you thats such good timing
You its a good day when jdh uploads
please make a video about your setup! Your vim looks really awesome for c++
Using a buffer for data going in an out and then parsing messages in bulk makes TCP/IP super happy. It's a streaming protocol, not a messaging protocol. Your header can be used to see if you have a complete message or need to just let the program do other things and check again when it's done processing game logic. If 100 messages come in between frames and you process them all at once, your game appears to be much smoother. And you can break actions up between multiple messages simplifying your game code.
yep that's what's going on for this game! I didn't have time to show the ~2-3k lines of packet handling/serialization/netcode here but basically the packet buffers (a big loop that send()s outgoing packets and recv()s incoming packets asynchonously, (de)serializes them, and dumps them into a buffer) run on a separate thread and then the client/server process/apply them when they have time to keep the simulation running smoothly on both sides
when either client/server enqueue a packet, the packets are pushed onto a thread-local buffer which is flushed (copied over to the packet handling thread) at the end of each frame (for the client) or the end of each tick (for the server) so it doesn't get in the way of anything else
This video is awesome, thank you!
As someone getting started with programming and taking a long time to grasp things. I feel like jdh be flexing on me .. 😢 Good video! 👍
I love your vids! Not sure if its really your thing but would love to see what youd be able to do in a big game jam like GMTK
man! i realy love the game, the devlog too! maybe if this gets released it can be a fun mutiplayer party roguelike! maybe i can share some ideas for spells, like a spelll that spawn lil minions to help you (like necromancy), anyway fun project!
Super cool, getting a real Gauntlet vibe from this.
Your amazing, so inspiring thanks for the great vid
It looks great so far! Do you plan to implement some sort of NAT traversal protocol or just have clients do port forwarding?
great video! enjoyed :)
Please continue this game it has so much potential
Nice video as always, I have no idea how C works and no idea what anything you say means but your videos are still entertaining
Cudos to you for writing your own netcode! I bit the bullet and wrote my own networking engine after years of dealing with a buggy library. Can recommend.
Great content!
hey man, you're pretty good at this stuff
This is amazing, building everything from scratch without a game engine is insane! Congrats!
Now a question, how did you manage do solve port forwarding on the multiplayer aspect? I have been having a hard time being able to connect a P2P connection in the public netword CSharp due to not being able to acess the public IP of another machine. My games work on a local network with local IPs but not over the internet
I absolutely love you sp much❤❤ cant belive you gave us a will to live again🎉
Yoo lets go a new video from my favourite programmer
You just explained my networking project thank you ! Haha
by far my favourite youtube dev 🙌🙌
13:50 this bug 🔥🔥
really would like to see it as real mechanic in some game
Thats what i thought, its a feature 😂
Hi! Would you consider doing again coding livestreams here or on twitch? I find them really entertaining.
I can 100% relate the pain in the networking part of the video, I atleast had unity to deal with the complex stuff, but I feel you
would love to see a video about your nvim workflow
how did you spend like 2 days and make some really good graphics with particle systems and color transitions, but the rest of the week you spent on netcode?
like to me the first part of actually making the game seems a lot harder, but in the video you mostly didn't really go into details about it. i know that the video is about making multiplayer game but it would be also good to hear about the rest of the game mechanics
That game looks hella fun!
where can we download this? I wanted to try this game watching your video makes me curious about the hands-on gameplay 🙂🙂. Great video btw.
You should try Swift one of these days. Works great with C code like SDL from my testing. Keep it up!
Hey man! I really like your videos. Can you tell me the stuff you use to create and edit these videos and the drawing software you use for the graphics as well 😊
A new vid by the GOAT ^^ I will just bury myself in awe, picking up my jaw after it dropped . . . I am too stupid for the world... But you sir, please continue to be awesome :)
Status effects applying to everything sounds like a fun idea. I'm a firm believer in multiplayer games giving you the ability to screw over your teammates (and yourself). Works really well in Lethal Company.
the scope creep is incredible
Dude how on earth did you learn to code this well. My brain can’t even fathom.
jo, what software do you use for video editing. Could you at some point show some of your workflow/setup? I would love to hear back :). Cheers
Very interesting!
small feedback: at 10:43, that brief comment on the top left is hard to read it you pause the video at fullscreen on a computer, because the title of the video occupies that space
I recently got a mac and I was wondering what compiler you use for your C code on mac... and if you dont use mac im still interested.
I use the latest clang (not the builtin one!) which you can install with homebrew
As a fellow software engineer it’s impressive what you’re able to achieve in such a short time. We all say we can do things in a week, seldom does anyone produce something that looks this good in twice the time.
ur videos are so good
great vid love you
looks great
Can you make a Q&A , we need to know how you learned all this and what editor you're using
I personally like to use the actions with an os matrix to build in other operating systems. Maybe try that when you decide to release on itch
Somehow from the first 2 minutes I correctly guessed what sockets and ports are, which it took me 2 minutes to finally decide to google, not really because it might be important in the video later but also definitely not because I will need it ever again. I just did somehow for some reason
I've tried to tinker with the in-depth explanation of the "trick" because I had never delved too much into C macros, but it looks like it doesn't work if any of the ???_FIELDS macros tries to pass more than one field name... It makes sense, because DO_FIELD_DESC expects exactly two arguments, one of which already passed in since it's the struct's type, but I don't know if I'm missing something. It looks like "fields" is supposed to hold more than one field, but I don't see how it could be possible for ???_FIELDS to expand to more than one... Unless rewritten, but how would you go about that? Would you have to write a recursive version that extracts one parameter at a time until a different macro is expanded because only one field is left? Is macro overloading even a thing?
ah i can see how that might be a little confusing from the example - each ???_FIELDS macro can have multiple lines after each (each for one field), like _F(field1, __VA_ARGS__) \ _F(field2, __VA_ARGS__)
and so on. The important thing is that “_F” is expanded for each field name :)
this is actually awesome
Finally a new upload
That's an incredibly productive week!
u r back!
man you have inspired me to do so much stuff, this channel is like a gem in a pile of shit that is modern youtube
You are a genius 👏
Very cool video
for so little days of work that looks really sick
definitely want to play this game