Coding basic Entity Component System but I am dumb. Game Engine ep. #3

Поділитися
Вставка
  • Опубліковано 14 тра 2024
  • Am I moving backwards or forwards? Nice to see you again for another time in the C++ engine series. This was an "adventure" to say the least and I hope that you were pleased. This was more of a theoretical video in terms of what you saw, but we will soon get to use this more in practice.
    Thank you for watching!
    Resources:
    github.com/SanderMertens/ecs-faq - has a lot of general information and links around the web for existing ECS implementations.
    / ajmmertens - lots of articles from the same person about ECS.
    0:00 Intro
    1:08 The Plan Failure
    2:12 Why New Architecture
    3:11 Data Oriented Design
    4:21 Firewood Analogy Interlude
    5:24 ECS Basics
    7:04 Me Admitting I'm Dumb
    7:29 The Grind Starts
    8:15 Experience Sharing Interlude
    8:53 My Own C++ ECS
    10:51 HashMap Querying
    11:48 Component Archetypes
    12:05 Remapping Component Indexes
    12:43 A Small Demo Scene
    13:09 Future Plans
    13:46 I Know That I Know Nothing
    Music:
    Intro:
    Iron Jack-o-Lantern - TeknoAXE
    Guitar Interludes:
    Sardana - Kevin MacLeod
    Background:
    Awake - Emmit Fenn
    Vibing Over Venus - Kevin MacLeod
    On The Rocks - TrackTribe
    Staycation - Corbyn Kites

КОМЕНТАРІ • 20

  • @graphicstalk7609
    @graphicstalk7609 3 місяці тому +1

    Use tuples instead of vectors. Tuples allow you to have a dynamic array that contains multiple types.

    • @Code_Gains
      @Code_Gains  3 місяці тому +2

      Thanks for the tip. I will be sure to include tuples in my analysis once I come back to this in the future vids.

    • @timtreichel3161
      @timtreichel3161 2 місяці тому +5

      No I don't think this is a good if you want to go with an ECS architecture. You want the components to be stored continuously, for each component type. So going with a single vectors for each component is exactly the right way to go. Then you want to iterate over the components vectors individually when updating the game/simulation state. That way you have the most cash benefits.
      Code duplication can be avoided with templates. Looking up components can also be implemented with linear or binary search and will probably be fast enough in most cases. Dealing with hash maps brings their own draw back, but I guess it can be done and might be needed in some cases.

  • @ParanoicoBR
    @ParanoicoBR 5 місяців тому +2

    The internet historian style video but for programming. I love it! Keep up the good work, man!

  • @GTGTRIK
    @GTGTRIK 3 місяці тому +3

    This is really helpful on my own ECS journey. I've been struggling with the whole magic layer of "linking components to entities".

    • @Code_Gains
      @Code_Gains  3 місяці тому +1

      Glad to hear I helped someone

  • @anthonyapm
    @anthonyapm 3 місяці тому +2

    Good job man. I've been battling the same problems 😅

  • @basboerboom9328
    @basboerboom9328 3 місяці тому +1

    I feel your pain. I am currently on my countless'th iteration of ECS for my game. Every time I almost get a Eureka moment, I run into a problem with my ECS system.

  • @doce3609
    @doce3609 6 місяців тому +1

    i am loving it 👍🏻👍🏻

  • @drominitoketchup
    @drominitoketchup 3 місяці тому

    Nice, another guy who loves low level programming².
    Oh, I'm already a subscriber to your site, I didn't even notice 🤔

  • @thomasp9511
    @thomasp9511 6 місяців тому +1

    Keep it up champ💪

  • @dontknow7863
    @dontknow7863 6 місяців тому +1

    Best video so far ,,🔥💪😎

  • @liutaurasgaidamavicius1379
    @liutaurasgaidamavicius1379 6 місяців тому +2

    shadow wizard money gang

  • @arnoldaz
    @arnoldaz 6 місяців тому +3

    God programmer is back at it again. When you were explaining why you moved to ECS, is there any reason why do you think you need separate classes for Physics Sphere or Physics Trail Sphere? Can't you just have some parameters in Sphere class that can be set on or off for each functionality? Or even do dependency injection for components if they share some common base.
    Amazing video as always tho!

    • @Code_Gains
      @Code_Gains  6 місяців тому +2

      There is nothing inherently special with ECS that allows to solve this and you likely could make it work. In my case having separate classes in OOP would ensure that you are not wasting memory by having properties on objects that should not have these properties (like physics) and passing parameters to enable functionality would likely still have the same memory overhead issue.
      I did not even consider doing something like injecting components (I guess ECS is kind of similar in a sense?), but I would have to be honest that I had my mind set on ECS without much consideration for OOP to begin with since I have plans for large scale simulations.

  • @Doggy_Styles_Coding
    @Doggy_Styles_Coding 6 місяців тому

    looks cool :D cant find anything dump

    • @Code_Gains
      @Code_Gains  6 місяців тому +1

      Hopefully someone will. I need to live up to the title

  • @Felix-we7iq
    @Felix-we7iq 6 місяців тому +2

    Deciding what type of int the ID of an entity should be sure is the most difficult part of ecs

    • @Code_Gains
      @Code_Gains  6 місяців тому

      I think I will switch to size_t later :')

  • @stevenfarmer5203
    @stevenfarmer5203 4 місяці тому

    🤷 "promo sm"