Learning C++ and making a GAME WITHOUT A GAME ENGINE

Поділитися
Вставка
  • Опубліковано 25 лис 2024

КОМЕНТАРІ • 132

  • @Chadderbox
    @Chadderbox  3 роки тому +19

    I also learnt a bit of Python and made a game without a game engine in that, check out the video here: ua-cam.com/video/toqxn7l5rHU/v-deo.html

    • @franklimburns7938
      @franklimburns7938 2 роки тому +1

      Good video tho just thought maybe u could add that to ur next project. Very cool stuff man

    • @costelinha1867
      @costelinha1867 2 роки тому +1

      Python with pygame is a blast, I was wondering if it was worth it to try and learn some Lua to make some short projects with pico-8.

  • @sky_beast5129
    @sky_beast5129 2 роки тому +121

    C++: Have you ever heard of Memory leaks?
    Beginner C++ programmer: No.
    C++: *Would you like to?*

    • @greg77389
      @greg77389 2 роки тому +10

      And then there's seg faults...

    • @skilz8098
      @skilz8098 2 роки тому +4

      And there's invalid and dangling pointers and references...

    • @rmt3589
      @rmt3589 Рік тому +2

      I think UA-cam Shorts has a memory leak. Each short makes my phone run slower, till UA-cam crashes, then it's better.

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

      ​@@rmt3589 UA-cam shorts definitely entice an "attention span leak"...

    • @Ich_liebe_brezeln
      @Ich_liebe_brezeln Місяць тому +1

      tbf, good use of RAII makes it very difficult to have memleaks (unless you get the destructor wrong ofc). Segfaults can still be a problem, though.

  • @breadpebbles2603
    @breadpebbles2603 3 роки тому +161

    I'm learning C++ to make games as I can't run things like unity and unreal

    • @spekulatiu
      @spekulatiu 3 роки тому +24

      Me too...
      But i find no Tutorials on 3D game setups without Game Engine :(

    • @breadpebbles2603
      @breadpebbles2603 3 роки тому +23

      @@spekulatiu openGL or vulkan C++ tutorials is the way to go if you have s old CPU openGL is the way to go and at first it may seem like vulkan is supported but later on you might find out some extensions you need are not

    • @أدهم-ح6ط
      @أدهم-ح6ط 3 роки тому

      Me too very sad

    • @jossiefxd
      @jossiefxd 3 роки тому +7

      my pc can run unity it's just it takes to much storage

    • @Chadderbox
      @Chadderbox  3 роки тому +10

      @Jossiefxd same lol, I have tons of storage on my D drive but it still installs most of it to C and I'm running out.

  • @GamesBySaul
    @GamesBySaul 3 роки тому +15

    Great video! I am learning/using C++ now so hearing this was quite a good way of me going back over some of the basics (and I surprisingly remembered most of it!)

    • @Chadderbox
      @Chadderbox  3 роки тому +1

      Your superhot project does look awesome, I wanna see how far you can go with it.

    • @GamesBySaul
      @GamesBySaul 3 роки тому

      @@Chadderbox Thanks I appreciate that! (I'm wondering too X) ) - What's next for you though? Try out a new language? Using C++ more?

    • @Chadderbox
      @Chadderbox  3 роки тому

      I'm honestly not sure. I've been eying up Haxe, but I've also been challenged regarding my dislike of Lua, but I've got no internet and it is kinda hard to do both of those options right now.

    • @GamesBySaul
      @GamesBySaul 3 роки тому +1

      @@Chadderbox Oh yeah I saw about your internet issues, not heard of Haxe, so I'll have to Google that.
      But you using Lua would be rather funny, maybe a video "proving" why your dislike of Lua is justified

    • @Chadderbox
      @Chadderbox  3 роки тому +1

      I like this idea haha

  • @qwerty273
    @qwerty273 3 роки тому +12

    Collision is quite simple, and using AABB, it’s as easy as one ‘if’ statement.
    // If the first rectangle is in between the second rectangle horizontally
    // Meaning, that the left side of the first rectangle is to the left of the right side of the second rectangle
    // and the right side of the first rectangle, is to the right of the second rectangles left side
    if(x0+w0 > x1 && x0 < x1+w1 &&
    // And the first rectangle is in between the second rectangle vertically
    // Vice versa for the Y, same algorithm, but replace ‘x’ with ‘y’, and ‘w’ with ‘h’
    y0+h0 > y0 && y0 < y1+h1) {
    // Collision has occurred
    return true;
    }
    I know you probably know how to do this, but I just wanted to show an example of AABB with comments.

    • @Chadderbox
      @Chadderbox  3 роки тому

      Yep, AABB is awesome and it is what Raylib uses, but my problem tends to be using it on a larger scale and making something that doesn't destroy performance and is also expandable. I have never actually implemented AABB and it is pretty interesting, thanks!

    • @qwerty273
      @qwerty273 3 роки тому +2

      @@Chadderbox Oh ok, you’re welcome :). Yeah, using it on a large scale can be very expensive. One way that I’ve seen is to check the distance between the object (in your case, just x) then if it’s close enough calculate if it’s colliding. Player width + some large enough value like 64-96 could be what you might check against for example.
      It saves a bit on performance, but there are probably better ways.

    • @islandcave8738
      @islandcave8738 2 роки тому

      Thats the basics of collission detection, but collission detection is a whole field in itself.
      Quadtrees, octtrees, mid-frame collissions, detecting which sides or edges collided, between-frame collissions of rotating or morphing objects, pixel perfect collission, etc and different combination of these concepts

  • @VioletGiraffe
    @VioletGiraffe 2 роки тому +13

    Managing memory in C++ is not hard at all (unlike C), but it requires that you use the right abstractions/tools and do not use the wrong ones, e. g. do not do raw memory management at all if you can avoid it (in 99.5% of the cases you can). So it is hard for a beginner until you learn what to do and what not to do.

  • @whenthethebeansstrikeback6728
    @whenthethebeansstrikeback6728 2 роки тому +11

    Reject Game Engine, return to C/C++

  • @pekkak.1411
    @pekkak.1411 3 роки тому +8

    "I don't like the way headers work". There is now new feature in latest C++ where you can use "modules". So no more #include nighmares :). I was just looking it myself, I like the idea.

  • @CharcoolDev
    @CharcoolDev 3 роки тому +11

    Game looks cool! It’s amazing that you even made that without a game engine

  • @jonathanmatta7902
    @jonathanmatta7902 3 роки тому +8

    The videos are short, entertaining and informative
    Noice
    Love it!

  • @johnreyesogon8424
    @johnreyesogon8424 2 роки тому +1

    Bro your really great starting from scratch that is so nerve cracking keep it up!!! you have a bright future up ahead

  • @williammoiser8652
    @williammoiser8652 2 роки тому +38

    Just an FYI on your code, switching out std::vector for std::list did not fix your issues, just covered them up.
    What is happening is two things:
    1) When you delete an Enemy, you don't remove it from the list so the update function calls update on a "Dead" enemy.
    2) When you do remove objects from gameObjects, it invalidates all the iteration references causing the loop to overrun the bounds of allocated storage. The main way you could fix this is by adding a "garbage" array that stores the pointers that need to be removed, then remove them after iterating, rather than removing them on the spot.
    Additionaly, if you are going to new a bunch of things, you can wrap them in std::unique_pointer or std::shared_pointer so that delete will be called automatically when it goes out of scope.
    I hope you do more C++ projects in the future as this was very entertaining to watch. Good Job!

    • @DrZygote214
      @DrZygote214 Рік тому +4

      The way i fix this is by iterating *backwards* over the list. The crash probably happens when you wanna delete and remove the last spaceship in the list, but then your size became smaller and your current index is invalid. But iterate backwards and you can delete and remove at the same time and just continue on. I know it sounds weird at first but if you just spell out the code and look at it, you'll see how. I think this is a much better solution cuz no extra list to create and maintain, but you do have to remember the right order of the backwards list for important stuff.

    • @Scotty-vs4lf
      @Scotty-vs4lf Рік тому +1

      @@DrZygote214 at first i thought it wouldnt work but 5 minutes later i realized the devils in the details. i forgot when u iterate in c++, your not just taking array[i--] ur actually iterating to the current previous object, so if index 4 removed index 3, then next it wouldnt do dostuff(array[3]) it would end up being dostuff(array[2])
      if that makes any sense. ive been using c too much

  • @TylerGreen
    @TylerGreen 3 роки тому +2

    This was really interesting. I agree about the library and headers with C++

  • @achyuththouta6957
    @achyuththouta6957 2 роки тому +6

    I tried making something like this using SDL libraries some time ago. It's really difficult and requires some linear algebra. There was a tutorial online too. Don't remember the name though

  • @pauloassis7649
    @pauloassis7649 Місяць тому

    Well done! But you need to make the destructor virtual if the class is part of inheritance.

  • @barj
    @barj 3 роки тому +3

    Awesome dude. Welcome to cpp gang

    • @Chadderbox
      @Chadderbox  3 роки тому

      Thanks a lot, I think I might stay with it for a bit :)

  • @MorganIron
    @MorganIron 2 роки тому +1

    I just completed my Associate of Science in Software & Database Development and had a semester of C++, I remember it being fairly easy... but that's literally all I can remember about it.😅 I can't remember a single project that I did. It was my thickest textbook too. 🤷‍♂️ I've spent the majority of my time with Python(for PC and Raspberry Pi) and Java in Android.

    • @nikolais6452
      @nikolais6452 2 роки тому

      c++ is super difficult, when you start to dive in to more complex code (bad error messages is huge oversight), a quote from the creator is: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off"

  • @danser_theplayer01
    @danser_theplayer01 2 місяці тому

    A list is apparently like a javascript array, an object with some hash shenanigans going on so when you add or remove values to it they have a designated ordered index.
    A vector is a solid block in memory (typed array in javascript) which is probably why you crashed, adding and removing from that is a bad idea...
    That's how I recognised what's going on, just to make sure I had to look up if a c++ vector is what I think it is.

    • @Ich_liebe_brezeln
      @Ich_liebe_brezeln Місяць тому

      Actually, a list c++ is a doubly linked list (you also have forward_list which is a singly linked list), it's still ok to modify from one as the process of insertion and deletion does not change the place in memory of the other objects, keeping stuff like iterators and references to its contents valid. C++ also contains map and unordered_map which I guess they are closer to what you describe in your first point.

  • @KeyserTheRedBeard
    @KeyserTheRedBeard 2 роки тому +1

    fascinating content Chadderbox. I broke the thumbs up on your video. Maintain up the superior work.

  • @georgecop9538
    @georgecop9538 2 роки тому

    you can make something like a garbage collection in C++ : create a mem_area class and add free/delete in the destructor

  • @Chevifier
    @Chevifier Рік тому

    Try Making a game with an arduino kit with an LCD display. It was fun. I dont even want to pull it down. It has 3 buttons(requiring 3 wires each) and the LCD display hooked up to a Breadboard and Arduino Uno😅

  • @oosubhisara
    @oosubhisara 2 роки тому +1

    What I don't like about C++ is header files and build system. With Dlang I get things done faster and it's easier to maintain.

  • @gideonunger7284
    @gideonunger7284 2 роки тому +2

    "didnt have a problem with pointers"
    "idk why vector crashes but list doesnt"
    dont think you did understand them after all buddy xD

  • @deaffatalbruno
    @deaffatalbruno Рік тому

    using smart pointer is kind of a memory management for C++. shared and weak ones normally do the trick.

    • @Chadderbox
      @Chadderbox  Рік тому

      Interesting, I'll have to learn about them :)

    • @deaffatalbruno
      @deaffatalbruno Рік тому

      @@Chadderbox def, they are bread and butter in C++,... shared pointer is the best to managed lifetime of object, while weak pointer is like an observer, that might want to interact with an object, but doesn't want to keep it alive.

  • @ChadderboxDev
    @ChadderboxDev 3 роки тому +2

    what would you call the greatest video game ever (excluding that one about them things, you know, the one where you have to do something to complete the missions then when all the missions are over the game ends, you know, the game that was on steam and had music in it, you know, the one that was made by them people in that country with the government, you know, the game with the mechanics, like, you know the one where if you press buttons on your keyboard/mouse things happen, you know, excluding that one, and portal 2)

  • @TimelessGamingSoftware
    @TimelessGamingSoftware 5 місяців тому +3

    raylib is a game engine

  • @nachaboy2991
    @nachaboy2991 Рік тому

    Im going to make my dream games with this

  • @nubdevice
    @nubdevice 2 місяці тому

    This guy knows. Raylib rocks.

  • @menaced.
    @menaced. 2 роки тому

    Im learning c++ to use openGL better than java so i wouldn’t need to worry so much about performance in the future. i thought this would give some tips.. maybe on ur next one

  • @thebricktop
    @thebricktop 2 роки тому +1

    barjis video went private

    • @Chadderbox
      @Chadderbox  2 роки тому

      Yeah I noticed a few days ago when I tried to send it to a friend

    • @thebricktop
      @thebricktop 2 роки тому

      @@Chadderbox any good replacement for my students?

    • @Chadderbox
      @Chadderbox  2 роки тому +1

      I've asked Barji to see if he can unprivate it, but for now it might be worth looking at mingw-w64.org
      Edit: I should add that I don't really intend for my content to be used for education since I am more of a "professional idiot" than teacher and often I don't really know what is going on.

    • @thebricktop
      @thebricktop 2 роки тому

      @@Chadderbox so am I but I'm getting paid

    • @Chadderbox
      @Chadderbox  2 роки тому

      The video should be unlisted now

  • @yukoshiii999
    @yukoshiii999 2 роки тому

    you aren't a setup master without a set of cans around your neck.. I'm wearing a set now even though I don't know what I'm doing! LOL!

  • @StarFury2
    @StarFury2 Рік тому

    While the headline is not wrong, it can be a bit misleading - raylib is a framework but it could be considered as game/multimedia language as well.

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

    Non-virtial destructors in non-final classes is a horrible idea

  • @QUIZTIME184
    @QUIZTIME184 7 місяців тому

    Can you make 3d game without game engine but in c++. I know you all redy uploded a video but in c.

  • @hmmmidkkk
    @hmmmidkkk 11 місяців тому

    As a consumer of your product(video) I think you should add more visual stuff instead of just having text that's just my thought tho

  • @islandcave8738
    @islandcave8738 2 роки тому

    No boost libraries!? What about the stl!? Well its good practice to program things from scratch if you have the time.

    • @Chadderbox
      @Chadderbox  2 роки тому +1

      No boost libraries, only pain.

  • @xaralabosxatzoglou3631
    @xaralabosxatzoglou3631 2 роки тому

    Fr you are very underrated.

  • @Steveplays28
    @Steveplays28 3 роки тому

    Well done Chadder! :D

  • @craftyryte
    @craftyryte 2 роки тому

    Raylib has collision sysytem inbuilt

  • @LetThereBeMayhem
    @LetThereBeMayhem 3 роки тому +1

    How'd you learn Raylib and C++? Did you read documentation or use tutorials? I'm having troubles with it.

    • @Chadderbox
      @Chadderbox  3 роки тому

      Read the documentation (the raylib cheatsheet is amazing), along with talking to people in the community and generally having an idea of how object oriented languages worked beforehand.

    • @LetThereBeMayhem
      @LetThereBeMayhem 3 роки тому +1

      @@Chadderbox Thanks.

  • @ChiefAsian
    @ChiefAsian Рік тому

    Hey, I would like to know if you made your own code from scratch for this project. I'm asking because I'm doing coursework for my Computer Science class in which my project is making a game in C++ - the marks for the project being your own code. If it is, could you give some tips? My own coursework is due in 2 months and i've had to switch project ideas entirely. Thank you.

  • @itsME-dc4vm
    @itsME-dc4vm 3 роки тому +2

    nicee ;D

  • @syaoranli7869
    @syaoranli7869 2 роки тому

    Can you not allocate some of that memory onto an external hard drive to make room in your ram? Genuinely asking because idk what it means to run out of memory

    • @Chadderbox
      @Chadderbox  2 роки тому

      Well, you only have a certain amount of bytes in your RAM, so when you use them all there is no memory left, and the program can't make new things so it crashes. Windows actually does have something where it will try to move some bits of memory onto your hard drive so you can use more, but it is ridiculously slow and not a good idea.

  • @guisande
    @guisande 2 роки тому

    Nice video bro, could you tell me the color scheme of the code in the blue background? I found quite beautiful. +1 subscriber

    • @Chadderbox
      @Chadderbox  2 роки тому +1

      Likely monokai vibrant amped, you might recognise the creator. It's only available for VSCode though.

  • @hitthemoney
    @hitthemoney 2 роки тому

    I did something similar and it was soooo annoying

  • @franklimburns7938
    @franklimburns7938 2 роки тому

    U should have had gameplay of ur game at the end

  • @eamon7629
    @eamon7629 2 роки тому

    the cake was a lie

  • @makra42069
    @makra42069 3 роки тому

    best of luck!

  • @DevlogBill
    @DevlogBill Рік тому

    Hi Chadderbox, I've been programming on my own for about 1.5 years and coding for me is a hobby as well as an end goal which is it get a job. From time to time, I will stop what I am doing which is learning by creating projects which is now Kotlin and Android and sometimes Python with Django. But lately I've been itching to try out C++. I tried out both C and C++ and it seems C++ is more flexible, and C is harder to create an array, I just suck maybe you can create an array with C? I don't know?
    Anyways, I plan on playing around with C++ for only a couple of days maybe 2 weeks before returning to Android development with Kotlin. I need some ideas for making something. Are there any tiny projects you could recommend even if it is a console project? Google isn't being kind to me and won't give me any cool recommendations, thanks.

    • @Chadderbox
      @Chadderbox  Рік тому

      I love finding cool frameworks and making small games, because they often require you to understand a lot about the programming language, so you learn a lot.

  • @fatimanisar8399
    @fatimanisar8399 2 роки тому

    Can we make a game in C++ without using classes

    • @Chadderbox
      @Chadderbox  2 роки тому

      No

    • @arifkasim3241
      @arifkasim3241 2 роки тому

      @@Chadderbox Why not?

    • @Chadderbox
      @Chadderbox  2 роки тому

      Because otherwise it would just be C

    • @arifkasim3241
      @arifkasim3241 2 роки тому +1

      @@Chadderbox Yes 😁, however I would like to know does any of that inheritance, polymorphism, abstraction stuff ever come into use for game programming. Classes are useful but that can be done using structs and pointers.

    • @Chironexe
      @Chironexe 2 роки тому

      @@arifkasim3241 Yeah, for example you could create a Monster class that's inherited by Goblin. The monster class has a virtual void attack() = 0; that allows you to take that method and change it however you want. This is a veeeeeery simple example, but you probably get the gist of it.

  • @discaymusic
    @discaymusic Рік тому

    Where's the game?

  • @thg1nrediar
    @thg1nrediar 2 роки тому

    good

  • @Lita1
    @Lita1 2 роки тому

    👍

  • @nitrogenez
    @nitrogenez 2 роки тому

    muck.

  • @sampkr
    @sampkr 2 роки тому +1

    700th like :D

  • @StellarHarbor
    @StellarHarbor Рік тому

    Where is course lol, another useless video