Video není dostupné.
Omlouváme se.

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

Sdílet
Vložit
  • čas přidán 31. 07. 2021
  • I decided to finally take the plunge and learn C++. In this video, I use the Raylib game framework to make a simple space shooter.
    //Links:
    Source code: github.com/Cee...
    Propulsion: bit.ly/Propulsi...
    Barji's tutorial: • Video
    Discord: bit.ly/Chadder...
    Space Shooter Environment Asset: ansimuz.itch.i...
    //Videos you might enjoy:
    Inspiration for this video (aside from the countless requests too): • Making a C++ Game with...
    Making a game without a game engine in Python: • Making a GAME WITHOUT ...
    I Put The BIGGEST Game Devs in a Boxing Match (feat. Dani): • i made a multiplayer b...
    Going all in on my Rust Voxel Engine: • Going all in on my Rus...
    #chadderbox

Komentáře • 125

  • @Chadderbox
    @Chadderbox  Před 2 lety +19

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

    • @franklimburns7938
      @franklimburns7938 Před 2 lety +1

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

    • @costelinha1867
      @costelinha1867 Před 2 lety +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 Před 2 lety +105

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

    • @greg77389
      @greg77389 Před 2 lety +9

      And then there's seg faults...

    • @skilz8098
      @skilz8098 Před rokem +4

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

    • @rmt3589
      @rmt3589 Před 11 měsíci +2

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

    • @dylancode
      @dylancode Před 2 měsíci

      ​@@rmt3589 CZcams shorts definitely entice an "attention span leak"...

  • @breadpebbles2603
    @breadpebbles2603 Před 3 lety +148

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

    • @spekulatiu
      @spekulatiu Před 2 lety +23

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

    • @breadpebbles2603
      @breadpebbles2603 Před 2 lety +20

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

    • @user-mm9cj2pn9r
      @user-mm9cj2pn9r Před 2 lety

      Me too very sad

    • @jossiefxd
      @jossiefxd Před 2 lety +6

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

    • @Chadderbox
      @Chadderbox  Před 2 lety +9

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

  • @whenthethebeansstrikeback6728

    Reject Game Engine, return to C/C++

  • @GamesBySaul
    @GamesBySaul Před 3 lety +14

    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  Před 3 lety +1

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

    • @GamesBySaul
      @GamesBySaul Před 3 lety

      @@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  Před 3 lety

      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 Před 3 lety +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  Před 3 lety +1

      I like this idea haha

  • @VioletGiraffe
    @VioletGiraffe Před 2 lety +11

    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.

  • @qwerty273
    @qwerty273 Před 3 lety +11

    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  Před 3 lety

      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 Před 3 lety +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 Před 2 lety

      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

  • @pekkak.1411
    @pekkak.1411 Před 2 lety +7

    "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 Před 3 lety +11

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

  • @williammoiser8652
    @williammoiser8652 Před rokem +37

    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 Před rokem +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 Před rokem +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

  • @jonathanmatta7902
    @jonathanmatta7902 Před 3 lety +7

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

  • @barj
    @barj Před 3 lety +3

    Awesome dude. Welcome to cpp gang

    • @Chadderbox
      @Chadderbox  Před 3 lety

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

  • @achyuththouta6957
    @achyuththouta6957 Před rokem +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

  • @KeyserTheRedBeard
    @KeyserTheRedBeard Před 2 lety +1

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

  • @TylerGreen
    @TylerGreen Před 3 lety +2

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

  • @gideonunger7284
    @gideonunger7284 Před rokem +2

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

  • @johnreyesogon8424
    @johnreyesogon8424 Před rokem

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

  • @MorganIron
    @MorganIron Před 2 lety +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 Před 2 lety

      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"

  • @georgecop9538
    @georgecop9538 Před 2 lety

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

  • @Chevifier
    @Chevifier Před 10 měsíci

    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 Před 2 lety +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.

  • @Ddotsun
    @Ddotsun Před 2 měsíci +2

    raylib is a game engine

  • @Steveplays28
    @Steveplays28 Před 3 lety

    Well done Chadder! :D

  • @ChadderboxDev
    @ChadderboxDev Před 2 lety +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)

  • @nachaboy2991
    @nachaboy2991 Před 10 měsíci

    Im going to make my dream games with this

  • @LetThereBeMayhem
    @LetThereBeMayhem Před 2 lety +1

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

    • @Chadderbox
      @Chadderbox  Před 2 lety

      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 Před 2 lety +1

      @@Chadderbox Thanks.

  • @ChiefAsian
    @ChiefAsian Před rokem

    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.

  • @hmmmidkkk
    @hmmmidkkk Před 8 měsíci

    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

  • @StarFury2
    @StarFury2 Před rokem

    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.

  • @menaced.
    @menaced. Před 2 lety

    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

  • @meowninja2407
    @meowninja2407 Před 26 dny

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

  • @3darts598
    @3darts598 Před 4 měsíci

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

  • @deaffatalbruno
    @deaffatalbruno Před rokem

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

    • @Chadderbox
      @Chadderbox  Před rokem

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

    • @deaffatalbruno
      @deaffatalbruno Před rokem

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

  • @yukoshiii999
    @yukoshiii999 Před 2 lety

    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!

  • @xaralabosxatzoglou3631

    Fr you are very underrated.

  • @itsME-dc4vm
    @itsME-dc4vm Před 3 lety +2

    nicee ;D

  • @syaoranli7869
    @syaoranli7869 Před 2 lety

    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  Před 2 lety

      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.

  • @thebricktop
    @thebricktop Před rokem +1

    barjis video went private

    • @Chadderbox
      @Chadderbox  Před rokem

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

    • @thebricktop
      @thebricktop Před rokem

      @@Chadderbox any good replacement for my students?

    • @Chadderbox
      @Chadderbox  Před rokem +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 Před rokem

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

    • @Chadderbox
      @Chadderbox  Před rokem

      The video should be unlisted now

  • @islandcave8738
    @islandcave8738 Před 2 lety

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

  • @makra42069
    @makra42069 Před 3 lety

    best of luck!

  • @soldierbirb
    @soldierbirb Před 2 lety

    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  Před 2 lety +1

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

  • @DevlogBill
    @DevlogBill Před rokem

    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  Před rokem

      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.

  • @craftyryte
    @craftyryte Před 2 lety

    Raylib has collision sysytem inbuilt

  • @eamon7629
    @eamon7629 Před rokem

    the cake was a lie

  • @franklimburns7938
    @franklimburns7938 Před 2 lety

    U should have had gameplay of ur game at the end

  • @thg1nrediar
    @thg1nrediar Před 2 lety

    good

  • @fatimanisar8399
    @fatimanisar8399 Před 2 lety

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

    • @Chadderbox
      @Chadderbox  Před 2 lety

      No

    • @arifkasim3241
      @arifkasim3241 Před 2 lety

      @@Chadderbox Why not?

    • @Chadderbox
      @Chadderbox  Před 2 lety

      Because otherwise it would just be C

    • @arifkasim3241
      @arifkasim3241 Před 2 lety +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 Před 2 lety

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

  • @hitthemoney
    @hitthemoney Před 2 lety

    I did something similar and it was soooo annoying

  • @Lita1
    @Lita1 Před 2 lety

    👍

  • @discaymusic
    @discaymusic Před rokem

    Where's the game?

  • @brownish-fox3194
    @brownish-fox3194 Před 2 lety +1

    700th like :D

  • @nitrogenez
    @nitrogenez Před 2 lety

    muck.

  • @StellarHarbor
    @StellarHarbor Před rokem

    Where is course lol, another useless video