He wrote this out BY HAND? // Code Review

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 พ.ย. 2024

ความคิดเห็น • 313

  • @TheCherno
    @TheCherno  หลายเดือนก่อน +36

    Hope you enjoyed the video! Check the description if you want me to review your code.
    Also don't forget you can try everything Brilliant has to offer-free-for a full 30 days, visit brilliant.org/TheCherno . You’ll also get 20% off an annual premium subscription.

    • @yingcheng1589
      @yingcheng1589 หลายเดือนก่อน

      Cherno make a python teaching 😊series

    • @TheFrankvHoof
      @TheFrankvHoof หลายเดือนก่อน

      You don't type that out by hand.
      You have an intern do it for you! 😂

    • @layqwo4274
      @layqwo4274 24 วันที่ผ่านมา

      Hi Cherno! Can you please tell what Visual Studio theme you are using or is it a custom one, cause i haven't been able to find smth like this. Thank you in advance

  • @saurabhmehta7681
    @saurabhmehta7681 หลายเดือนก่อน +319

    Thanks for reviewing my code Cherno! I agree that there could be better way to structure the code, like having a reference to renderer rather than making it static and so on. And the initialization does seem weird when I look at it now after a year :) Thanks for the awesome feedback, I will definitely checkout the full length review on Patreon!

    • @AftercastGames
      @AftercastGames หลายเดือนก่อน +9

      I love Cherno, and I love this channel, but I actually disagree with him here. I use static classes and variables by default, and only use non-static instances when needed. Especially in games, where you will only ever have one game engine and one window, both of those classes can just be static, and can be called by any other code. However, as a general rule, I normally try to minimize the number of static classes that one class interacts with.
      This is a great little project, btw. Good job.

    • @devmishra18
      @devmishra18 หลายเดือนก่อน +4

      Interesting take, I personally think that Static classes makes it very difficult to extend the code or write tests for the code which are very important aspects of software development imo. Obviously, some use of static classes can be justified, but if you are depending on it too much then it sounds like a code smell to me.
      Being said that I am open to learning more about this.

    • @Unhinged-yu6km
      @Unhinged-yu6km หลายเดือนก่อน +5

      L indian coder hahaha

    • @malekith6522
      @malekith6522 หลายเดือนก่อน +10

      ​@@AftercastGames With static classes, you can’t predict when they will be initialized. This can be problematic when the order of initialization is crucial. For example, your logger needs to be initialized before the game engine itself, or network components need to be initialized separately or any other resources.
      As a rule of thumb, you should think twice before using static classes. Consider whether it even needs to be a class, or if it could just be functions within a namespace.

    • @lukasjetu9776
      @lukasjetu9776 23 วันที่ผ่านมา +1

      @@Unhinged-yu6km your name fits you pretty well

  • @Aoun-Hussain
    @Aoun-Hussain หลายเดือนก่อน +187

    Whoever made this game
    I LOVE YOU
    Because I'm working on my first game and was having second thoughts that it's not worth going through with it becuase it looks just like "Skyward Scammer". But now I'm going to finish this project if it's the last thing I do

    • @saurabhmehta7681
      @saurabhmehta7681 หลายเดือนก่อน +25

      Glad to hear. Go for it! :)

    • @fangornthewise
      @fangornthewise หลายเดือนก่อน +6

      Name checks out.

    • @w花b
      @w花b หลายเดือนก่อน +2

      ​@@fangornthewise lol

    • @charmander2k
      @charmander2k 9 วันที่ผ่านมา

      ​@@fangornthewiseyour name doesn't check out

  • @RandomGeometryDashStuff
    @RandomGeometryDashStuff หลายเดือนก่อน +62

    02:50 also not use "unsigned long" or "signed long" because it's same size as memory address (`sizeof(void*)`) on linux, but 32 bit on windows (both 32bit and 64bit)
    edit: I mean don't assume `sizeof(void*)==sizeof(long)` if you care about windows

    • @DataToTheZero
      @DataToTheZero หลายเดือนก่อน +9

      What's next, you going to insist on proper usage of size_t, intptr_t, and uintptr_t? Suddenly int32_t and int64_t are your new best friends? And then all bit arithmetic can't be 8 based but instead needs to count from CHAR_BIT because magic numbers are bad and just maybe somebody will be targeting a more than 8-bit per char system? pfft, portability is for porters.
      PS, "explain the difference between size_t, intptr_t, and uintptr_t?" is a good interview question.

    • @Firestar-rm8df
      @Firestar-rm8df หลายเดือนก่อน +24

      @@DataToTheZero I expect you are being sarcastic, but to everyone else reading this, please just use the standard types for portable code. It's not that much harder to just use the portable types, and if you care about the bit layout of a type you should really be being explicit about it anyway. Please. Please. Please I don't want to debug more issues that work on one OS and CPU but don't on another because the length of a type changed.

    • @mytech6779
      @mytech6779 หลายเดือนก่อน

      Meh. Windows is not always 32b long.
      Anyway int64_t uint64_t are sufficient. Or int_fast32_t if 32b is big enough but you want it more portable between 32b and 64b machines

    • @RandomGeometryDashStuff
      @RandomGeometryDashStuff หลายเดือนก่อน

      @@mytech6779which windows `4!=sizeof(long)`?

  • @AgentM124
    @AgentM124 หลายเดือนก่อน +104

    for April fools you got to review perfect code and then suggest things that make it worse. Or, review something atrocious and say that it's perfect. idk. but it has potential :)

    • @pandalonium
      @pandalonium หลายเดือนก่อน +10

      But… what is perfect code?

    • @no_name4796
      @no_name4796 หลายเดือนก่อน

      Perfect code is basically what haskell programmers masturbate to

    • @Al-tt6tj
      @Al-tt6tj หลายเดือนก่อน +5

      he would lose credibility if he did that

    • @roberthoople
      @roberthoople หลายเดือนก่อน +11

      Maybe not as an April Fools, but I like the idea.
      From experience, there's a lot of value in sometimes tackling a problem from an unusual angle. This is especially true for learning as well, but unfortunately we love our one-size-fits-all way of teaching, and such things are frowned upon.
      I used to get in trouble, in my Math classes, for using the answer key (when available) to work backwards, in order to actually understand the concept we were learning, because their traditional method of lecture, notes, then work, didn't work for me. All the stuff that never "stuck" with me, was almost always the stuff I didn't have the answer keys for, or the times that I was outright prohibited from using my "backward" method to understand them; getting my text book (with its answer keys) taken away, and then being given only photocopies of the assignment from that textbook.
      So this idea could be a very interesting way to teach certain advanced topics that people really struggle with. Start out with that "perfect" code, which is so cryptic and unrecognizable to the student that they'll normally just give up on it, but then break it down into "bad" code, which despite being "bad" (and maybe funny to more advanced programmers), lands up cutting through all the in-between concepts and creating a path back to the recognizable and comfortable concepts that the amateur does understand (aka: bad code).
      Plus, it would be very entertaining.

    • @xeridea
      @xeridea หลายเดือนก่อน +3

      @@pandalonium int main() { return 0; }

  • @Roman8707
    @Roman8707 หลายเดือนก่อน +64

    5:12 is that seriously Mario Raceway from Super Mario Kart??? XD

    • @TheCherno
      @TheCherno  หลายเดือนก่อน +12

      lol I didn’t even notice that!

    • @MattRose30000
      @MattRose30000 หลายเดือนก่อน +20

      Javidx9 made a video a while ago where he made a mode7-like effect and used this exact tilemap. I guess they just took the code and pasted it into here.

    • @zoobloik2
      @zoobloik2 2 ชั่วโมงที่ผ่านมา

      I immediately thought the same as soon as I saw it - straight away I was like "have they seriously ripped off the mario kart track?" 😂

  • @anon_y_mousse
    @anon_y_mousse หลายเดือนก่อน +7

    They've proposed and supposedly adopted for C++26 #embed which is already available for C23. We're not quite there as far as it being usable for the majority because people don't update their compilers but once a decade. However, I'm excited for the future because if C or C++ gets it, you know other languages will copy it. I also like the filesystem::path technique because you can just write paths like you're always on a good OS, such as Linux, but then get the correct delimiter and whatnot. The real bonus is that you can just about use plain text in your source code when defining paths instead of everything in a long string or using any kind of format stuff.

  • @billy.d3v
    @billy.d3v หลายเดือนก่อน +106

    3:43 - "Okay, im excited, lets play this gam..." *ERROR: THIS CODE EXECUTION CANNOT PROCEED...*
    Lmao xD

    • @JavedAlam-ce4mu
      @JavedAlam-ce4mu หลายเดือนก่อน +12

      Lol guess he skipped over the troubleshooting and left it in the Patreon version.

    • @billy.d3v
      @billy.d3v หลายเดือนก่อน +4

      @@JavedAlam-ce4mu ye, but funny cut xd

    • @WibleWobble
      @WibleWobble หลายเดือนก่อน +5

      I think it was a fairly simple fix at least, looks like that thing that happens when you forget to put the dll in the same directory as the exe

  • @irrelevant_noob
    @irrelevant_noob 19 วันที่ผ่านมา +3

    20:52 bug introduced: you changed the expected structure of the image folders, and now all the sprites need to be folders containing a single file called ".png"... 👀

  • @doglitbug
    @doglitbug หลายเดือนก่อน +12

    Totally seeing the remnants of one lone coder engine here!

  • @vadimkokielov2173
    @vadimkokielov2173 หลายเดือนก่อน +20

    Hey, been lurk watching your channel for three years now. Time to give back, всего наилучшего

    • @TheCherno
      @TheCherno  หลายเดือนก่อน +3

      Благодарю! ❤

  • @daviddursty3215
    @daviddursty3215 26 วันที่ผ่านมา +5

    When you say to "structure your code like a tree" at 9:00, I think what you mean to say is to "prefer object composition over class inheritance". This is by no means a new concept. There's a great section on this in the 1995 book "Design Patterns" in Section 1.6 under "Inheritance versus Composition". Yes, I quoted the section there. If you don't have the book, I'd recommend buying it (or checking it out from the library). It's a classic in Software Engineering literature, with much information still relevant.

  • @afterschool2594
    @afterschool2594 หลายเดือนก่อน +25

    2:39 I usually support Linux and Windows but not MacOS since I have never used it

    • @ismbks
      @ismbks หลายเดือนก่อน

      that's not very chill

    • @gaming53wishmaster71
      @gaming53wishmaster71 หลายเดือนก่อน +1

      And me idk if i would support windows or mac as for i think windows has to meany holes and is a dieing os linux to the win

    • @vibaj16
      @vibaj16 หลายเดือนก่อน +3

      @@gaming53wishmaster71 And I don't try to support anything other than my particular device b/c I'm lazy

    • @WHYUNODYLAN
      @WHYUNODYLAN หลายเดือนก่อน +5

      MacOS can be a nightmare to support

    • @toby9999
      @toby9999 หลายเดือนก่อน +4

      ​@gaming53wishmaster71 Windows has a vastly larger user base than Linux as a desktop os, and this will continue. Linux is unlikely to displace Windows any time soon. Linux is way behind, and it's an inconsistent mess.

  • @exxon47_
    @exxon47_ หลายเดือนก่อน +8

    15:46 I'd like to mention that in C23 there is a preprocessor directive called #embed built-in that allows you to construct a byte array from a binary file unfortunately this feature was not added to the C++23 standard however C++ may get this feature one day which would be cool

    • @0LoneTech
      @0LoneTech หลายเดือนก่อน

      It's a little silly. The purpose of #embed is to bypass chunks of the compiler when all you want to do is embed a bunch of data. I.e. it avoids parsing an autogenerated array literal typically 2-5 times the size of the input data. But if what you needed done was bypassing the compiler, you can simply link it in the first place, e.g. objcopy -I binary -O elf64-little inputfile object.o. So the advantage is single entry point to the compiler and constexpr sizeof. C++ is all about adding stuff and painfully slow compiles so it'll probably get there.

    • @anon_y_mousse
      @anon_y_mousse หลายเดือนก่อน +5

      It's proposed for C++26, so in about 12 years when everyone updates to that version you can count on seeing it everywhere. I don't know why the other guy doesn't like it, but it would actually speed up compiles because instead of parsing a giant comma separated array of 0x??'s you'll get direct inclusion. The objcopy method isn't exactly portable either.

  • @spicynoodle7419
    @spicynoodle7419 หลายเดือนก่อน +44

    Holy crap, they have overloaded the division operator to use it for concatenating OS path strings

    • @Mad3011
      @Mad3011 หลายเดือนก่อน +18

      Yep, and here I thought overloading the shift operators for io was bad already. xD

    • @VerMishelb
      @VerMishelb หลายเดือนก่อน +7

      IIRC it is this way to make it separate from regular concatenation with +, because different OS can use a different path divider. Even though most of them support the forward slash out of the box.

    • @AlexMax2742
      @AlexMax2742 หลายเดือนก่อน +1

      Even worse when you accidentally use that overload on a URI out of habit.

    • @AlexMax2742
      @AlexMax2742 หลายเดือนก่อน +7

      @@Mad3011 Overloading bitshifting is bad enough, but my hot take is that overloading addition on strings was a bad idea. Addition is a fundamentally different operation than concatenation, because it doesn't compose like addition - there is no such thing as subtracting two strings, nor multiplying or dividing.

    • @bartolhrg7609
      @bartolhrg7609 หลายเดือนก่อน +2

      ​@@AlexMax2742 there doesn't need to be subtraction
      In the simplest terms: plus sign means addition, and concatenation is adding characters of the 2nd string to the end of the 1st
      It is not necessarily tied to subtraction

  • @comalab2387
    @comalab2387 หลายเดือนก่อน +10

    You don't put stuff in a c'tor that can fail, hence the init function which offers a return type.

    • @Firestar-rm8df
      @Firestar-rm8df หลายเดือนก่อน +5

      Normally I'd agree, but this is the init for the main game loop... if this fails what are you really going to do? I say log an error and then terminate.

    • @comalab2387
      @comalab2387 หลายเดือนก่อน +1

      @@Firestar-rm8df it's a matter of principle. If you have a class function that can fail, let the user decide what to do. Imagine documenting this. "Here's the Game class. It has a void init() function which can fail but you'll never know. Just let your program crash or whatever."

    • @RetroAndChill
      @RetroAndChill หลายเดือนก่อน +3

      @@Firestar-rm8dfI think in that case maybe but I still think it’s less error prone to have a factory function that returns an std::optional than just having the constructor throw an exception since it forced the user of your API to deal with the error explicitly. In Java its a somewhat different story because of checked exceptions, but in C++ I would do it that way.

    • @Firestar-rm8df
      @Firestar-rm8df หลายเดือนก่อน

      I agree if this was something else. But it isn't. It's the top level of your application code. Looking at how the rest of this is structured an error message followed by termination is fine.
      I would never recommend throwing an exception from a constructor or destructor, that is messy imo. I prefer explicit return types.
      Returning a std::optional from a factory is a good alternative for similar cases. Especially if you make the factory function a friend of the class, and then restrict instantiation to force the use of the factory for initialization of the object. I especially like this as you can't forget to initialize portions(something I see all too often with init functions).
      That said, for a top level object in application code like this I still think it's kind of overkill. Now if this was a library, or something, again, yes, definitely do this, or if you are setting up a reusable framework for other games yeah you should do it. It's cleaner, and you still have a single call where you can pass all the required parameters so you don't get half initialized objects. But if the main application code for your application can't initialize really, 99% of the time all you are going to want to do is log an error and terminate nearly immediately. Maybe attempt to dump a crash file to disk, pop up an error msgbox, or attempt send a signal to some other process that we are about to force terminate if we got far enough we can do basic IO, but that's about it really for most cases. This isn't an embedded safety critical system where we keep the software limping along in whatever state we can as much as we can just so we can maybe mitigate something. It really doesn't make sense to do anything else in this case.

  • @rohitaug
    @rohitaug หลายเดือนก่อน +17

    There are some benefits to using a fixed array for assets. You could have an enum with the names of all assets defined at compile time, which can then be used to pass in asset handles globally anywhere in your code just using that enum value. A file watcher would discover the assets at runtime so you need a gui based editor to know what the assets are.

    • @anoomage
      @anoomage หลายเดือนก่อน

      In my system I get my assets based on their file path (for example "Resources/Meshes/cube.obj")
      I supposed that I would load/get assets only on application init, so I don't think I need something like a superfast std::vector, or an ultra-fast std::array. A fast enough hashmap should do the job. The benefit is that I can load my assets from their on-disk path/name, which is very convenient.

    • @andersr9545
      @andersr9545 หลายเดือนก่อน +4

      another trick is to let the last value of the enum be named size, then you can for instance store an std::array if you want to do what he did in the video. the array is then automatically set to the correct size

    • @MrDavibu
      @MrDavibu หลายเดือนก่อน

      I think what you mean is not possible in C++.
      In C++ an enum is represented as literals, that are translated into numbers at compile time. There are no strings in enums in C++.
      I mean you could use a hashmap inside C++ that saves the name as string and the "handle" as ID if you want.
      But I think it's better to abstract the concepts you use for assets away and have a document that specifies what asset is what concept (e.g. floor, wall, object, player, enemy). You could still specify these mappings inside a ,.cpp or .h file if you have a smaller game or want to avoid parsing a file. This can also be useful for development, because later on you only have to write a parser that fills in the data structure you already have and the rest should still work,

    • @rohitaug
      @rohitaug หลายเดือนก่อน

      @@MrDavibu See andersr9595's comment. I mean the exact same thing, using the enum as an index into an array of strings. Maybe I didn't word it properly...

    • @SchmittySchfin
      @SchmittySchfin หลายเดือนก่อน +1

      I worked on a contract where the company’s developers did that - an enum and a string array (technically char*), where they’d index into the string array with the enum. It was the worst thing ever implemented and the source of way too many bugs.
      You never ever want code to be structured in a way that two separate data sources MUST line up to work correctly. All it takes is one value to be removed, changed, or moved in only one of the sources for everything to collapse… which is exactly what happened with the contract I worked on. So yeah, don’t do that.
      There’s no benefit at all to what you suggested - only ways it WILL fail.

  • @JavedAlam-ce4mu
    @JavedAlam-ce4mu หลายเดือนก่อน +4

    What a speedrun! Harder than it looks, that was pretty impressive for a first go.

  • @stepa10online27
    @stepa10online27 หลายเดือนก่อน +397

    How did you get my code?

    • @ndrechtseiter
      @ndrechtseiter หลายเดือนก่อน +27

      Этот код не только твой, тёзка... 🌚

    • @filimanistr6124
      @filimanistr6124 หลายเดือนก่อน +17

      он наш

    • @TheRealZitroX
      @TheRealZitroX หลายเดือนก่อน +10

      @@ndrechtseiter speak english.

    • @ndrechtseiter
      @ndrechtseiter หลายเดือนก่อน +38

      @@TheRealZitroX 🤓☝️

    • @ndrechtseiter
      @ndrechtseiter หลายเดือนก่อน +60

      @@TheRealZitroX you have a "translate to English" button, by the way.

  • @Baekstrom
    @Baekstrom หลายเดือนก่อน +6

    I'm just happy to see that in 2024 there are still newcomers to programming that choose C++ as their language of choice. Recruiting for C++ jobs is already getting rather difficult as other languages gain popularity.

    • @RetroAndChill
      @RetroAndChill หลายเดือนก่อน +5

      Rust programmers learning there’s no Rust jobs

    • @RetroAndChill
      @RetroAndChill หลายเดือนก่อน +3

      Realtalk thought, I love C++ because it gives you options for relative safety but still allows you to do hacky things if you need to

    • @adygombos4469
      @adygombos4469 29 วันที่ผ่านมา

      @@RetroAndChill Rust lets you do wacky stuff too, just makes you put it in an unsafe block so it's easier to debug.

    • @samuelclemens6841
      @samuelclemens6841 16 วันที่ผ่านมา

      @@adygombos4469 And then you might as well use C++

    • @rretro2042
      @rretro2042 2 วันที่ผ่านมา

      ​@@adygombos4469too much hassle with rust. c/c++ is much easier

  • @dnishimura
    @dnishimura หลายเดือนก่อน +14

    Congrats on nearing end of October with 666K subscribers :)

    • @gaming53wishmaster71
      @gaming53wishmaster71 หลายเดือนก่อน +3

      Wow i dident even notice he had 666k wow lol happy Halloween in deed

  • @ChadMourning
    @ChadMourning หลายเดือนก่อน +3

    Ending reminds me of Mode 7 from SNES.

  • @rideorhitchhike3347
    @rideorhitchhike3347 หลายเดือนก่อน +4

    Hahaha, 18:55 looks like Pirate Software (Maldavius Figtree)'s code.

  • @Ayodehi
    @Ayodehi หลายเดือนก่อน +4

    You make me feel so old that you don't immediately recognize Mode 7 graphics from Mario Kart on the SNES :)

  • @notdeus3834
    @notdeus3834 หลายเดือนก่อน +4

    Amazing vid as always, Cherno. Could you please make a video dedicated strictly to best practices?

    • @dawiddulian2403
      @dawiddulian2403 หลายเดือนก่อน +2

      That's his entire channel

  • @chotenque6877
    @chotenque6877 หลายเดือนก่อน +10

    bro saw that macro with replacement text and got legit pissed lmaoo

  • @sumikomei
    @sumikomei หลายเดือนก่อน +2

    This is interesting, so much to take in from all this lmao also extreeemely interested in seeing the pseudo-3D rendering that reminds me of SNES and Genesis games.

  • @astralengineer1
    @astralengineer1 หลายเดือนก่อน

    I’m a web dev, no idea what is going on in any of your videos but I still love to watch them.

  • @grubzer1369
    @grubzer1369 หลายเดือนก่อน +4

    2:58 - also dont use platform-specific compiler C++ extensions. Got caught on GCC dynamic c-style arrays not compiling on windows msvc

    • @HypocriticalLemur
      @HypocriticalLemur 29 วันที่ผ่านมา

      What do you mean? What was the problem exactly?

    • @grubzer1369
      @grubzer1369 29 วันที่ผ่านมา

      @@HypocriticalLemur syntax like:
      Int size = getIntFromUser();
      Int[size] myArr = {0};
      Wont work in msvc since c-style array with dynamic size is a gcc c++ extension

  • @kfitch42
    @kfitch42 หลายเดือนก่อน +19

    This is arguably nitpicking, but I would rather see GameEngine as a member of RPG_Game instead of a parent class. Having it as a parent class fails the classic IS-A vs HAS-A test. RPG_Game IS A GameEngine ? RPG_Game HAS A GameEngine works better.

  • @BobChess
    @BobChess หลายเดือนก่อน +6

    I initializer my pointer arr without using for loop

  • @Draeith
    @Draeith 16 ชั่วโมงที่ผ่านมา

    @ 16:14 Not a headafile! Anything but those!

  • @vxlaris
    @vxlaris หลายเดือนก่อน +3

    4:55 the outplay thoo

  • @LacklusterFilms
    @LacklusterFilms หลายเดือนก่อน +4

    Woupd you ever go over some of the godot engine source code? Would be cool to hear from a game engine guy what you like or don't like about it's code

  • @kevinkkirimii
    @kevinkkirimii หลายเดือนก่อน +2

    Regardless of the issues, what a nice game.

  • @Zettymaster
    @Zettymaster 7 วันที่ผ่านมา

    one thing about the std::filesystem::path concatonation you did: you did it wrong! you used the operator/ instead of operator+ which adds the separator between the filename and its extension, if done like you showed.

  • @daniel.watching
    @daniel.watching หลายเดือนก่อน +2

    15:45 Is there a better or more standard way to embed binary data in C? Often I have a bunch of data structures I have to pre-compute. I could massively reduce the start-up time for some code with those things pre-baked but I can't think of an elegant way to include an arbitrary binary blob inside a C binary (other than explicitly hex encoding it in a header file which feels hacky).
    Also I don't think this is good practice for fonts. It makes the code less readable with no performance benefits. Just make sure you include the font file in the source so people don't need to install a system font to run your project. Embedding as binary is a little extra.

    • @Stroopwafe1
      @Stroopwafe1 หลายเดือนก่อน +3

      C23 introduced the #embed preprocessor statement. If using a newer version is not a hindrance, you can take a look at that?

    • @VerMishelb
      @VerMishelb หลายเดือนก่อน +2

      To add to the above-mentioned #embed directive, another way for older C standard would be to use assembly, though I'm not sure how cross platform that would be. This was a common thing among the GBA devs because it's faster to compile and guarantees the alignment if done properly. You can read about this in TONC Bitmap section. Using arrays is still fine otherwise, as long as they are const and are not defined in the header file, which would cause *every* file using the array to compile it again.

    • @JanSoltan-wj1hs
      @JanSoltan-wj1hs หลายเดือนก่อน +1

      ​@@VerMishelbYou can declare e.g. mFontBytes as extern in a header and define the actual data in a separate source file

    • @0LoneTech
      @0LoneTech หลายเดือนก่อน

      The source file in this case is the resource file (e.g. the .ttf), to link it you can wrap it in an object file. E.g. with GNU binutils:
      objcopy -I binary myfont.ttf -O elf64-little myfont.o
      You'd then access it with something like SDL_RWFromConstMem(&_binary_myfont_ttf_start, &_binary_myfont_ttf_size). Unfortunately the tooling for this isn't standard, but it might be available in your build system.

    • @mytech6779
      @mytech6779 หลายเดือนก่อน

      In C++ you could try consteval to force pre-computing during compile. It's a bit like constexpr but constexpr is allowed to fall back to runtime execution while consteval is an error if not computed at compile time. (*do your own research, I'm a bit fatigued)

  • @der.Schtefan
    @der.Schtefan 17 วันที่ผ่านมา

    This is obviously Mode 7 on a SNES. I am 100% sure they use a SNES emulator and use that to draw the end screen ;)

  • @Egalobert
    @Egalobert หลายเดือนก่อน +1

    The nitialization is definitely kinda 'weird' .. some things being implicitly initialized on the Objects creation, some requiring an explicit call to 'init', and even 'startGameLoop' seems to do some further initialization.. i guess that both the RAII and the deferred approaches are reasonable, but it should at least be consistent (along related Objects)

  • @0z2ae
    @0z2ae 22 วันที่ผ่านมา +1

    17:44 how did he change ASSETS to assets so fast??

  • @juansolo1617
    @juansolo1617 12 วันที่ผ่านมา

    These kinds of classes are called "onesies." A lot of people get really angry about onesies, but even highly-polished API's use them. There's no reason to avoid them.

  • @DanielChristensen-mb5qr
    @DanielChristensen-mb5qr 10 วันที่ผ่านมา

    It took me 3 minutes to figure out what this "card" you kept talking about was. I realized you're just an aussie pronouncing "code" :D

  • @andersr9545
    @andersr9545 หลายเดือนก่อน +1

    what are the advantages of using filesysystem::path over string? seems a bit annoying to me, is it just that you can write path/to instead of path + «/« + to?

    • @jamesmnguyen
      @jamesmnguyen หลายเดือนก่อน

      More functionality I assume

    • @merseyviking
      @merseyviking หลายเดือนก่อน +10

      It handles platform specific stuff such as path separators; it does path validation; it can normalize paths; you can get absolute or relative paths; change extensions, and a load more. It also means it's easier for a human to understand its sematics.

    • @dawiddulian2403
      @dawiddulian2403 หลายเดือนก่อน +2

      You can also easily: list the whole directory, create and destroy files or folders, check if file/folder exists, get access to every part of the address, etc

    • @Firestar-rm8df
      @Firestar-rm8df หลายเดือนก่อน +1

      in addition to what's already been stated, it adds some extra type saftey as you know it should be a path and handled as such. And you can leverage this in a bunch of ways, such as with templates.

    • @ChaoticRay
      @ChaoticRay หลายเดือนก่อน

      @@merseyviking Is there something like this for C? I somehow forgot that different platforms have different path separators. That would be very useful.

  • @gsestream
    @gsestream หลายเดือนก่อน

    no, even ascii shader files are separate includes. but that needs to be editable. the font file does not.

    • @gsestream
      @gsestream หลายเดือนก่อน

      make an opencl video

  • @calabrais
    @calabrais หลายเดือนก่อน +1

    "I absolutely love the tiling. The fact that this texture does not tile whatsoever, but it's so confidently used."
    😂💀

  • @KDTechverse
    @KDTechverse หลายเดือนก่อน

    The Cherno : that was a journey after finishing the game in 5 mins. 😂

  • @yoshmeme931
    @yoshmeme931 หลายเดือนก่อน

    I love the way you say 'code' lol

  • @pillboxgaming4144
    @pillboxgaming4144 8 วันที่ผ่านมา

    You didnt notice the ground textures being from Mario Kart? Wonder why Mario Kart?

  • @maervo4179
    @maervo4179 23 วันที่ผ่านมา +1

    I think every developer has the famous singleton phase, it will stop after someone ask you to test your code and then you see why singletons are bad 😂

  • @skeleton_craftGaming
    @skeleton_craftGaming หลายเดือนก่อน

    the background of the end was DP1 from mario kart ... ...

  • @scarletevans4474
    @scarletevans4474 28 วันที่ผ่านมา

    5:13 should we be able to see the curvature of the Earth here, especially on that height? The horizon looks completely flat, is the Earth really flat? 😱

  • @3amael
    @3amael 21 วันที่ผ่านมา

    One simpe rule for mewbies to make their code and life better... composition over inheritance!

  • @theprakashrdas
    @theprakashrdas หลายเดือนก่อน

    I wanted to check if you have some thoughts on COW(Copy on Write) in C++. can you make a video on it.

  • @donw4889
    @donw4889 หลายเดือนก่อน +1

    Spending any time developing for Mac seems like a waste 3% of PC are Macs. If it is not a mobile app really point to think about those OS.

  • @Necropheliac
    @Necropheliac 23 วันที่ผ่านมา +1

    I hate seeing code files that could have been YAML or even XML or JSON.

  • @ItzCPU_
    @ItzCPU_ 15 ชั่วโมงที่ผ่านมา

    Me watching the video whilst having no Idea what is going on

  • @Daniel_Zhu_a6f
    @Daniel_Zhu_a6f 24 วันที่ผ่านมา

    main function consisting of 2 meaningful lines is my biggest trigger. why do people do this is beyond my understanding

  • @OrangeIND-
    @OrangeIND- หลายเดือนก่อน +4

    Do Tokyospiff Code review 😂

    • @0ShinigamiDN0
      @0ShinigamiDN0 หลายเดือนก่อน

      This would be amazing 🤣

  • @lukafireman
    @lukafireman 18 วันที่ผ่านมา

    Other platforms?
    No other platforms support gaming other than consoles, cheers.

  • @Sollace
    @Sollace หลายเดือนก่อน +25

    15:47 NO. God no. For the love of hod, do NOT embed resources as cpp header files. Include the ttf in your project and load it in the first time you need it. No one will subtract points if you do that (except this guy apparently).

    • @JasonGrace69
      @JasonGrace69 หลายเดือนก่อน +12

      Due to this actually being a big demand, c23 adds #embed as a preprocessor definition to do exactly what you are saying not to do. This kind of thing is great if you want a resource to be available at compile time or just to avoid wasting resources unnecessarily at runtime. Its becoming more popular now since worrying about binary size is really a thing of the past.

    • @brod515
      @brod515 หลายเดือนก่อน +2

      why not ?

    • @connorsweeney6210
      @connorsweeney6210 หลายเดือนก่อน +2

      Why not?

    • @JohnDoe-jk3vv
      @JohnDoe-jk3vv หลายเดือนก่อน +1

      Why not, brony?

    • @Sollace
      @Sollace หลายเดือนก่อน +5

      @@connorsweeney6210 You're taking a file, that you can view, easily, and turning it into a jumble of bytes. What's going to happen if you need to edit or replace the file? You can't. You have to pull up the original, make the change, and re-run whatever conversion. It's better to just have your code read the file. Embedding it in your code isn't going to make it run faster to any degree that matters. Maybe it did when we were coding for the NES but not any more. You're trading away maintainability for little to no reason.

  • @kotofyt
    @kotofyt หลายเดือนก่อน +7

    I don’t think that code review should be "paid", because it is made to improve reviewed code

    • @deadliaski
      @deadliaski 29 วันที่ผ่านมา +1

      jeeeez! He doesn't owe you a thing and he's published a free review any way

    • @cicin.
      @cicin. 21 วันที่ผ่านมา +1

      ​@@deadliaskiYeah people complain way too much when it comes to making stuff paid as a content creator

  • @urisinger3412
    @urisinger3412 หลายเดือนก่อน +6

    Do you accept rust code?

    • @zanagi
      @zanagi หลายเดือนก่อน +10

      Hes the cherno for c++ maybe need the rherno for rust

    • @bluesillybeard
      @bluesillybeard หลายเดือนก่อน +1

      He's done C# before, and he said he's open to accepting other languages. Although I don't know about Rust in particular...

    • @poleve5409
      @poleve5409 27 วันที่ผ่านมา

      ​@@zanagiLOL

  • @kdhupar0
    @kdhupar0 11 วันที่ผ่านมา

    Saurabh Mehta ×
    Soraab meta ♡

  • @Ron_DeForest
    @Ron_DeForest 11 วันที่ผ่านมา

    Just wondering. Have you ever rewritten someone’s code to make a more efficient program? More content potential.

  • @mattanimation
    @mattanimation หลายเดือนก่อน

    was that a map from wacky wheels?

  • @christ01011994
    @christ01011994 หลายเดือนก่อน +2

    Coding structure can significantly improve overtime with experience if you are learning along the way.

  • @m.gredemptor2610
    @m.gredemptor2610 หลายเดือนก่อน +14

    I won't make apple ports simply out of spite.

  • @phill6859
    @phill6859 15 วันที่ผ่านมา

    The folder idea makes me think you have no idea what you are doing.

  • @roberthoople
    @roberthoople หลายเดือนก่อน

    @11:16 - How did you select all the static keywords like that?

    • @dmitrikozak7837
      @dmitrikozak7837 หลายเดือนก่อน +1

      Holding alt and dragging over the code allows a more squared highlight

    • @roberthoople
      @roberthoople หลายเดือนก่อน

      @@dmitrikozak7837 OMG!!!!
      You have literally made my week!
      Thank you.

  • @quintvandijk533
    @quintvandijk533 22 วันที่ผ่านมา

    Does anyone recognize the brand of his hoodie?

  • @aredrih6723
    @aredrih6723 หลายเดือนก่อน +4

    21:02 never used the filesystem path api before but shouldn't there be a + instead of a / between the filename and extension ?

    • @bronkolie
      @bronkolie หลายเดือนก่อน +3

      The std::filesystem::path class has the / operator overloaded to concatenate two paths, while adding a path separator in the middle if necessary

    • @aredrih6723
      @aredrih6723 หลายเดือนก่อน +4

      @@bronkolie sure, and I have no problem with the first use of the operator on the line.
      But the second is between the sprite name and the string ".png"; do you add a path separator between a file name and its extension ?

    • @bronkolie
      @bronkolie หลายเดือนก่อน +4

      @@aredrih6723 Damn, looks like you're right. It says in the docs "when appropriate", butI just checked, and it still adds a slash between a filename and extension, even if the extension is just a const char* or a std::string. Weird
      Edit: now that I think about it, you can have filenames like .gitignore or .bashrc. So assuming something is a file extension can't work

    • @0LoneTech
      @0LoneTech หลายเดือนก่อน

      Either path+".png" or replace_extension(path, "png").

  • @pablogguimaraes
    @pablogguimaraes หลายเดือนก่อน +1

    The Cherno make a series making an AI model (YOLO) , i think you teaching that stuff will be very exiting!

  • @Arkoto1
    @Arkoto1 วันที่ผ่านมา

    video starts at 3:44 . thank me later

  • @albertvanzyl366
    @albertvanzyl366 27 วันที่ผ่านมา

    Great video. Next video review please.

  • @Macciejable
    @Macciejable หลายเดือนก่อน +1

    I'm on minute 5, didn't see the code yet, but I love it. Best game 2024.

  • @ettyxcbyrcburcbtxcfhcdtyurt
    @ettyxcbyrcburcbtxcfhcdtyurt หลายเดือนก่อน

    i feel kinda bad id be infuriation if i was on the receiving end of this

  • @MisterEpsilon
    @MisterEpsilon 27 วันที่ผ่านมา

    Oh... I thought your name was ''Chemo", as in chemotherapy, oops

  • @kaosspectrum9805
    @kaosspectrum9805 หลายเดือนก่อน +2

    This is a straight rip from javid one lone coder the scene at the end

  • @oleksiistri8429
    @oleksiistri8429 29 วันที่ผ่านมา

    Damn, i do this all the time

  • @JosaxJaz
    @JosaxJaz 27 วันที่ผ่านมา

    Haven't done C++ in multiple years, haven't even really commented in a while, but man C++ looks way more complex than I remember it being.
    I've been using plain C for many years now at my courses in college and uni, and looking at C++ code now is just intimidating. I know Unreal Engine uses C++, so I should probably get back into it (I'm a game dev), but the amount of different definitions and ways of doing things is quite a lot. It seems like so many people have different opinions on how to do things in C++, rather than there being agreed-upon standards and such.

  • @DelicueMusic
    @DelicueMusic หลายเดือนก่อน

    When your subscriber count is stuck at 666K 😂

  • @dj10schannel
    @dj10schannel หลายเดือนก่อน

    Nice 😊

  • @Nitu-s7e
    @Nitu-s7e หลายเดือนก่อน +4

    Premature optimization is bad. This code is better than doing nothing,

    • @MrMoon-hy6pn
      @MrMoon-hy6pn หลายเดือนก่อน +3

      I’d hardly call taking a const reference to a string, initialising in one place, avoiding macros, avoiding creating objects that are mostly but not completely static, etc, premature optimisations. They just seem like logical tips and design choices.

    • @Nitu-s7e
      @Nitu-s7e หลายเดือนก่อน +3

      @@MrMoon-hy6pn My point was more like most people waste so much time thinking of organizing their code that they forget the problem they're trying to solve. This guy can fix his code as he gets more mature as a programmer but it is commendable that he put in his effort and made the project work in the first place.

    • @poleve5409
      @poleve5409 27 วันที่ผ่านมา

      ​@@Nitu-s7ebro the guy asks for a code review and got the code review, what is the problem here?

    • @Nitu-s7e
      @Nitu-s7e 27 วันที่ผ่านมา

      @@poleve5409 I don't.

  • @MrJay_0xJ
    @MrJay_0xJ หลายเดือนก่อน

    15:56 How can we embed the font and take byte into cpp? can u explain dear master? for example define the fonts in a global h file?

  • @fdelduquenobre
    @fdelduquenobre หลายเดือนก่อน

    Is he used to his feet?

  • @agnesakne4409
    @agnesakne4409 23 วันที่ผ่านมา

    love watchin you roasting this newbie wannabe sw engineer

  • @РусланЗаурбеков-з6е
    @РусланЗаурбеков-з6е 19 วันที่ผ่านมา

    100% new game engine in C++ and in SDL??? ))))

  • @adamrushford
    @adamrushford หลายเดือนก่อน +2

    lol it's not a TimeStamp Yan, it's a Card.

  • @YoungMetroid
    @YoungMetroid หลายเดือนก่อน

    Mr skill issues trying to roast others 🤣🤣

    • @toby9999
      @toby9999 หลายเดือนก่อน

      What does "skill issues" mean in this context? It's an often used phrase in programming comments. Is it a derogotory thing?

  • @TheBcoolGuy
    @TheBcoolGuy 13 วันที่ผ่านมา +1

    i am cming

  • @Aragubas
    @Aragubas หลายเดือนก่อน +1

    first :3
    I'd love you to code review my open source project after it's in a "working" state, do you also review open source projects?

    • @poleve5409
      @poleve5409 27 วันที่ผ่านมา +1

      The code he reviewed in this vid is open source so I would think yes lol

    • @Aragubas
      @Aragubas 27 วันที่ผ่านมา

      @@poleve5409 awesome!

  • @VakkaHUN
    @VakkaHUN หลายเดือนก่อน

    Do you sleep enough?

  • @RonyMarcolino
    @RonyMarcolino หลายเดือนก่อน

    Very interesting!

  • @someguy1428
    @someguy1428 หลายเดือนก่อน +1

    666k subs

  • @CatzHoek
    @CatzHoek หลายเดือนก่อน

    "I have the video linked up there" \*points in the corner\* twice!
    At this point just stop saying it. :) You never link it, ever. LIterally every time you say it you didn't link anything.

    • @poleve5409
      @poleve5409 27 วันที่ผ่านมา

      I honestly believe these videos are from 4 years ago before they removed the new annotations, and he's only uploading them now

  • @ahsanhafeez7631
    @ahsanhafeez7631 หลายเดือนก่อน

  • @ifracing
    @ifracing หลายเดือนก่อน

    Mariokart snes

  • @row-d
    @row-d หลายเดือนก่อน

    666k suscribers 😈

  • @SatvikkGuptaa
    @SatvikkGuptaa หลายเดือนก่อน +4

    some day i will understand the shit being talked about 💀💀💀💀

    • @acestandard6315
      @acestandard6315 หลายเดือนก่อน +1

      Some years ago I didn't understand shit
      Now I can make out some things 😂

    • @diabloolivero73
      @diabloolivero73 หลายเดือนก่อน

      ​@@acestandard6315Me too😂

  • @rubyciide5542
    @rubyciide5542 หลายเดือนก่อน +2

    Aren't we all writing it by hand? Or are you guys writing with smth else?