Programming a multiplayer game from scratch in 7 DAYS
HTML-код
- Опубликовано: 3 июн 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 - Наука
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
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!!:)
I was just checking your channel yesterday to see if you'd uploaded. I'm very excited to watch this one
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 :)
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
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.
One of the few places I can come to see games written at this low level, thank you for your content and hard work!!!
I was just hopin for a vid from u soon, great timing
1 week? Good lord that's very impressive good job man
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!
You are a great inspiration to me as someone learning to code. Great vid and congrats on that sponsorship
The monster loot catching on fire is some real dwarf fortress material. Great video and project as always!
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.
Small game side projects are very fun. Great video!
The game actually looks fun, and this video was really instructional. Thanks a lot jdh for your amazing content!👍
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.
This is insane, you'r an inspiration to me and i can only hope to come close to this level of expertise!
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
Congratulations, and thanks for the video, it’s amazing
Nice work! This looks really fun :P
Your skills are amazing, loved it
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().
please continue the last video's project!! it looks so damn good and fun
Looks really cool, great job!
YAY i just got re-obsessed with you thats such good timing
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 👍
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.
FINALLY! been waiting for another video forever!
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
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
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.
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
You its a good day when jdh uploads
please make a video about your setup! Your vim looks really awesome for c++
Super cool, getting a real Gauntlet vibe from this.
Love your vids dude! Awesome stuff
Someday you should consider a tutorial on how you set up your neovim and build with C… 🙃
This video is awesome, thank you!
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.
Yoo lets go a new video from my favourite programmer
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.?
great video! enjoyed :)
Please continue this game it has so much potential
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
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
It looks great so far! Do you plan to implement some sort of NAT traversal protocol or just have clients do port forwarding?
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
As someone getting started with programming and taking a long time to grasp things. I feel like jdh be flexing on me .. 😢 Good video! 👍
Your amazing, so inspiring thanks for the great vid
Great content!
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!
wake up hun, hes back.
He's about to cook for the whole family!
I'll get the broom...
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
by far my favourite youtube dev 🙌🙌
I absolutely love you sp much❤❤ cant belive you gave us a will to live again🎉
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 😊
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
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.
hey man, you're pretty good at this stuff
this is actually awesome
Finally a new upload
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
That game looks hella fun!
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.
would love to see a video about your nvim workflow
You just explained my networking project thank you ! Haha
How did you implement the equipment swapping visuals? (Does your engine library have skeletal animation?)
It's the man of the hour! Glad to see ya JDH!
i just like to program little games as a hobby, i am 100% self taught and after struggling to understand how to serialize non-basic types for a while now this motivated me to search for answers again - if you or anyone in the community have any input on that it'd be highly appreciated, and thanks for the motivational boost!
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
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 :)
17:54 Some what new here, what is it built to run on if not Windows or Linux? CromeOS lol?
u r back!
13:50 this bug 🔥🔥
really would like to see it as real mechanic in some game
Thats what i thought, its a feature 😂
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
Very interesting!
you gotta love this guy
insane skills man
He’s back
You should try Swift one of these days. Works great with C code like SDL from my testing. Keep it up!
great vid love you
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.
looks great
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
You are a genius 👏
your crazy good some people cant even make a multiplayer game with a game engine and you made it without a game engine
lmao what a perfect video
ive been doing socket programming with aes and shit and i learned that i hate openssl
as soon as i take a break this pops up
That's an incredibly productive week!
ur videos are so good
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
for so little days of work that looks really sick
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