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
  • НаукаНаука

Комментарии • 457

  • @tr7zw
    @tr7zw 4 месяца назад +2136

    Take a shot every time jdh starts a game from scratch

    • @jdh
      @jdh  4 месяца назад +621

      quick way to get alcohol poisoning

    • @siteking4289
      @siteking4289 4 месяца назад +162

      @@jdh Hard mode: When he implements shit on his own and trying to reinvent the wheel rather then using a robust library

    • @Finkelfunk
      @Finkelfunk 4 месяца назад +84

      @@siteking4289 So basically continue drinking constantly?

    • @sir_chaotic
      @sir_chaotic 4 месяца назад

      You're dead.
      No big surprise.

    • @domeen0gt895
      @domeen0gt895 4 месяца назад +40

      @@siteking4289 Tbh I can kinda respect his determination.

  • @onlysmiles4949
    @onlysmiles4949 4 месяца назад +406

    Honestly, the idea of enemies being able to light their loot drops on fire before they die is really funny ngl

    • @timecubed
      @timecubed 2 месяца назад +6

      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

    • @HexaflexagonFan
      @HexaflexagonFan 2 месяца назад +2

      It could be a decent balancing technique

    • @talltreecustoms
      @talltreecustoms Месяц назад +1

      its a feature. not a bug :)

  • @ViktorSarge
    @ViktorSarge 4 месяца назад +276

    Dude. You make it look reasonable and almost easy implementing things from scratch in C. That's a feat in and of itself.

    • @Nick-yq5uz
      @Nick-yq5uz 4 месяца назад +21

      After he added serialization to C++ I’m convinced he can do anything.

  • @btarg1
    @btarg1 4 месяца назад +484

    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

    • @jdh
      @jdh  4 месяца назад +194

      active hinderance or learning experience? you decide!

    • @robinHobin
      @robinHobin 4 месяца назад +15

      Both@@jdh

    • @flaviog141
      @flaviog141 4 месяца назад +11

      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.

    • @SolarShado
      @SolarShado 4 месяца назад +32

      @@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.

    • @atiedebee1020
      @atiedebee1020 4 месяца назад +3

      ​@@SolarShadoit's not part of the C standard library

  • @HisVirusness
    @HisVirusness 4 месяца назад +307

    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.

    • @cluelessadc
      @cluelessadc 4 месяца назад +45

      this guy is the best of us

    • @wildmaknae_
      @wildmaknae_ 2 месяца назад +1

      im an artist and feel so called out rn x)

    • @robinHobin
      @robinHobin Месяц назад

      It says in the vid for a split second he is still working on the cos but has nothing interesting to show rn

    • @keshi5541
      @keshi5541 Месяц назад

      Artists be the exact same 😂😂

  • @clintonhawkins8666
    @clintonhawkins8666 4 месяца назад +133

    I think the flaming coin bug should definitely stay!

    • @cometeova
      @cometeova 4 месяца назад +16

      Exactly - my first thought when I saw that part was "Is this a bug, or a feature?"

  • @spaghettiking653
    @spaghettiking653 4 месяца назад +48

    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.

  • @divine203
    @divine203 4 месяца назад +93

    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 ❤

  • @danielgysi5729
    @danielgysi5729 4 месяца назад +35

    The things you did in a week would've taken me at least a couple months. Your talent and work ethic are amazing

  • @lukasnick5511
    @lukasnick5511 4 месяца назад +14

    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!!:)

  • @Gavinwasalmostcool
    @Gavinwasalmostcool 4 месяца назад +2

    I was just checking your channel yesterday to see if you'd uploaded. I'm very excited to watch this one

  • @spluf1081
    @spluf1081 4 месяца назад +12

    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 :)

  • @eboatwright_
    @eboatwright_ 4 месяца назад +3

    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

  • @d_00
    @d_00 4 месяца назад +1

    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.

  • @nulifyer4460
    @nulifyer4460 4 месяца назад +2

    One of the few places I can come to see games written at this low level, thank you for your content and hard work!!!

  • @mdnghtppl0000
    @mdnghtppl0000 4 месяца назад +2

    I was just hopin for a vid from u soon, great timing

  • @hedwig7s
    @hedwig7s 4 месяца назад +28

    1 week? Good lord that's very impressive good job man

  • @jessieray6129
    @jessieray6129 3 месяца назад +3

    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.

  • @stevemcwin
    @stevemcwin 4 месяца назад

    Finally jdh finishing a game.
    Entertaining video as always, hope you make more soon!

  • @Wow-wk7eu
    @Wow-wk7eu 4 месяца назад +1

    You are a great inspiration to me as someone learning to code. Great vid and congrats on that sponsorship

  • @vitao95
    @vitao95 4 месяца назад +3

    The monster loot catching on fire is some real dwarf fortress material. Great video and project as always!

  • @alfredenglund
    @alfredenglund 2 месяца назад

    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.

  • @hengstus8411
    @hengstus8411 4 месяца назад

    Small game side projects are very fun. Great video!

  • @vaxaop7838
    @vaxaop7838 4 месяца назад +1

    The game actually looks fun, and this video was really instructional. Thanks a lot jdh for your amazing content!👍

  • @lilium724
    @lilium724 3 месяца назад +2

    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.

  • @neverix_3600
    @neverix_3600 4 месяца назад +2

    This is insane, you'r an inspiration to me and i can only hope to come close to this level of expertise!

  • @Baaqel
    @Baaqel 4 месяца назад +6

    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

    • @ezrakornfeld8436
      @ezrakornfeld8436 4 месяца назад

      Ok yes but that’s a theory. Occam’s razer.

    • @Baaqel
      @Baaqel 4 месяца назад +1

      @@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.

    • @jdh
      @jdh  4 месяца назад +1

      for sure! my example was definitely a bit contrived

    • @eDoc2020
      @eDoc2020 4 месяца назад

      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.

    • @Baaqel
      @Baaqel 4 месяца назад

      @@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

  • @robinou21
    @robinou21 3 месяца назад

    Congratulations, and thanks for the video, it’s amazing

  • @EranStockdale
    @EranStockdale 4 месяца назад

    Nice work! This looks really fun :P

  • @xoanaraujo
    @xoanaraujo 4 месяца назад

    Your skills are amazing, loved it

  • @goddtriffin
    @goddtriffin 4 месяца назад +14

    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().

  • @davidbasilefilho
    @davidbasilefilho 4 месяца назад

    please continue the last video's project!! it looks so damn good and fun

  • @rafaaaaaze
    @rafaaaaaze Месяц назад

    Looks really cool, great job!

  • @user-hn6eo9ej6f
    @user-hn6eo9ej6f 4 месяца назад

    YAY i just got re-obsessed with you thats such good timing

  • @idjles
    @idjles 4 месяца назад +14

    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.

  • @crefelder1
    @crefelder1 4 месяца назад

    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.

  • @btarg1
    @btarg1 4 месяца назад +32

    FINALLY! been waiting for another video forever!

  • @FallKK
    @FallKK 4 месяца назад +2

    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

  • @abyssaltheking
    @abyssaltheking 4 месяца назад +1

    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

  • @doggo_idk
    @doggo_idk 4 месяца назад +1

    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.

  • @aziwii4052
    @aziwii4052 3 месяца назад

    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

  • @magnusfrlund1605
    @magnusfrlund1605 4 месяца назад +8

    You its a good day when jdh uploads

  • @abrarmasumabir3809
    @abrarmasumabir3809 4 месяца назад +2

    please make a video about your setup! Your vim looks really awesome for c++

  • @GuildOfCalamity
    @GuildOfCalamity 4 месяца назад

    Super cool, getting a real Gauntlet vibe from this.

  • @trentlangford9050
    @trentlangford9050 4 месяца назад

    Love your vids dude! Awesome stuff
    Someday you should consider a tutorial on how you set up your neovim and build with C… 🙃

  • @exFAT.
    @exFAT. 4 месяца назад

    This video is awesome, thank you!

  • @krammehl
    @krammehl 4 месяца назад

    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.

  • @yiit9914
    @yiit9914 4 месяца назад

    Yoo lets go a new video from my favourite programmer

  • @Bozebo
    @Bozebo 4 месяца назад +3

    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

    • @jdh
      @jdh  4 месяца назад +2

      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.?

  • @gedaliakoehler6992
    @gedaliakoehler6992 4 месяца назад

    great video! enjoyed :)

  • @M_BRINE_85
    @M_BRINE_85 3 месяца назад +1

    Please continue this game it has so much potential

  • @tilted3167
    @tilted3167 4 месяца назад

    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

  • @bkucenski
    @bkucenski 4 месяца назад +2

    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.

    • @jdh
      @jdh  4 месяца назад +2

      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

    • @jdh
      @jdh  4 месяца назад +2

      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

  • @MrSpartan927
    @MrSpartan927 4 месяца назад

    It looks great so far! Do you plan to implement some sort of NAT traversal protocol or just have clients do port forwarding?

  • @Wyklepheph
    @Wyklepheph Месяц назад

    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

  • @Ketpain
    @Ketpain 4 месяца назад +1

    As someone getting started with programming and taking a long time to grasp things. I feel like jdh be flexing on me .. 😢 Good video! 👍

  • @JettMcColl
    @JettMcColl 4 месяца назад

    Your amazing, so inspiring thanks for the great vid

  • @skope2055
    @skope2055 4 месяца назад

    Great content!

  • @TomatoSaucey95
    @TomatoSaucey95 4 месяца назад

    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!

  • @Thzyr
    @Thzyr 4 месяца назад +100

    wake up hun, hes back.

    • @aserta
      @aserta 4 месяца назад +3

      He's about to cook for the whole family!

    • @domeen0gt895
      @domeen0gt895 4 месяца назад +1

      I'll get the broom...

  • @marsimplodation
    @marsimplodation 4 месяца назад +1

    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

  • @dxwn5367
    @dxwn5367 4 месяца назад

    by far my favourite youtube dev 🙌🙌

  • @dailydoseofshtposts6891
    @dailydoseofshtposts6891 4 месяца назад

    I absolutely love you sp much❤❤ cant belive you gave us a will to live again🎉

  • @korigamik
    @korigamik 4 месяца назад

    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 😊

  • @arthuroverissimo3165
    @arthuroverissimo3165 2 месяца назад

    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

  • @keaganrice8656
    @keaganrice8656 4 месяца назад

    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.

  • @philosophiabme
    @philosophiabme 4 месяца назад

    hey man, you're pretty good at this stuff

  • @ryann7760
    @ryann7760 4 месяца назад

    this is actually awesome

  • @gone357
    @gone357 4 месяца назад

    Finally a new upload

  • @baulus779
    @baulus779 4 месяца назад

    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

  • @PaGow
    @PaGow 4 месяца назад

    That game looks hella fun!

  • @Diamonddrake
    @Diamonddrake 4 месяца назад +1

    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.

  • @oiacopas
    @oiacopas 4 месяца назад

    would love to see a video about your nvim workflow

  • @dennisrobinson4739
    @dennisrobinson4739 3 месяца назад

    You just explained my networking project thank you ! Haha

  • @Test-iv4pm
    @Test-iv4pm 4 месяца назад

    How did you implement the equipment swapping visuals? (Does your engine library have skeletal animation?)

  • @Nunya58294
    @Nunya58294 4 месяца назад

    It's the man of the hour! Glad to see ya JDH!

  • @Lolboy30
    @Lolboy30 4 месяца назад

    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!

  • @HyperCodec
    @HyperCodec 4 месяца назад

    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

  • @INsanityDesign
    @INsanityDesign 4 месяца назад

    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 :)

  • @kylerd5663
    @kylerd5663 4 месяца назад

    17:54 Some what new here, what is it built to run on if not Windows or Linux? CromeOS lol?

  • @ethangalva
    @ethangalva 4 месяца назад

    u r back!

  • @icantstopsuffer
    @icantstopsuffer 4 месяца назад +4

    13:50 this bug 🔥🔥
    really would like to see it as real mechanic in some game

    • @oldgangster4119
      @oldgangster4119 4 месяца назад

      Thats what i thought, its a feature 😂

  • @JaniEU
    @JaniEU 4 месяца назад +1

    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

  • @Povilaz
    @Povilaz 4 месяца назад

    Very interesting!

  • @OpGaming-el5zk
    @OpGaming-el5zk 4 месяца назад

    you gotta love this guy

  • @vaiterius
    @vaiterius 4 месяца назад

    insane skills man

  • @featherless656
    @featherless656 4 месяца назад +1

    He’s back

  • @zaneenders
    @zaneenders 3 месяца назад

    You should try Swift one of these days. Works great with C code like SDL from my testing. Keep it up!

  • @realElo.2
    @realElo.2 4 месяца назад

    great vid love you

  • @chiranjeevinaidu3660
    @chiranjeevinaidu3660 4 месяца назад

    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.

  • @wanking9040
    @wanking9040 4 месяца назад

    looks great

  • @user-cd4bx6uq1y
    @user-cd4bx6uq1y 3 месяца назад +1

    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

  • @fedang
    @fedang 4 месяца назад

    You are a genius 👏

  • @R1fleman
    @R1fleman 4 месяца назад

    your crazy good some people cant even make a multiplayer game with a game engine and you made it without a game engine

  • @ari_archer
    @ari_archer 4 месяца назад

    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

  • @HarhaMedia
    @HarhaMedia 4 месяца назад

    That's an incredibly productive week!

  • @daylethewhale
    @daylethewhale 4 месяца назад

    ur videos are so good

  • @sillygaby_
    @sillygaby_ 4 месяца назад

    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

  • @randomgoose2606
    @randomgoose2606 4 месяца назад

    for so little days of work that looks really sick

  • @captheobbyist6434
    @captheobbyist6434 4 месяца назад +2

    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