Code-It-Yourself! Worms Finale Part #3 (C++)

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • The final part of my big project! Artificial Intelligence is given to the worms so they can destroy each other! Mwa ha ha... Anyway, here an AI state machine is used to allow the AI to manipulate the input controls instead of the player. It's a nice approach as it means the game and physics code is untouched.
    Big thanks to MaGetzUb from the OneLoneCoder Discord Server for the track - it's awesome!
    And for derivation of the projectile formula, this guy nails it: • Projectile Motion Tric...
    Source: github.com/One...
    Blog: www.onelonecode...
    Twitter: @javidx9
    Twitch: javidx9
    Discord: / discord

КОМЕНТАРІ • 75

  • @nicoletaanghel6147
    @nicoletaanghel6147 6 років тому +35

    Your teaching videos and programming skills are equaled by your commentator abilities ! ^^ It was really entertaining to listen to :)

    • @javidx9
      @javidx9  6 років тому +4

      Thanks Carmen! - I dont think i'll give up the day job to be a sports commentator just yet however :D

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

      @@javidx9 That explains the clarity and interest you are able to carry in your voice! A+ content.

  • @seditt5146
    @seditt5146 6 років тому +2

    Hey Javid Can we port this to a Java Script or maybe setup some Network support so we can play each other from Discord or something. It would be awesome if everyone from the chat room could get together and play some worms as we bullshit around with each other. :)

    • @javidx9
      @javidx9  6 років тому

      Hey Sedit, yeah a discord battle royale would be interesting!

  • @vitor-a12
    @vitor-a12 6 років тому +23

    NOOOO, GREEN TEAM LOST :(

    • @javidx9
      @javidx9  6 років тому +7

      WOOOO GO REDS!

  • @joelreijonen8813
    @joelreijonen8813 6 років тому +14

    Absolutely brilliant work!

    • @javidx9
      @javidx9  6 років тому +2

      Cheers Joel!

  • @spjewkes
    @spjewkes 6 років тому +3

    Nice work, David. Your channel has been one of the highlights for me this year. I'm really looking forward to what you come up with in 2018. In the meantime, have a good Christmas! :)

    • @javidx9
      @javidx9  6 років тому

      Thanks Steve! Such a nice thing to say! Have a good Christmas too!

  • @DavstrWrexham
    @DavstrWrexham 6 років тому +5

    That is mega cool. I'm going to have to get back into programming.

    • @javidx9
      @javidx9  6 років тому +1

      Good stuff Davstr, and good luck!

    • @DavstrWrexham
      @DavstrWrexham 6 років тому

      Thanks. I have an idea for a top down starship shooter, but I've no idea how to start. Any help would be very useful.

  • @NeilRoy
    @NeilRoy 6 років тому +2

    Great tutorial and I loved the ending! This reminded me of an artillery duel game I worked on in the '90s. You could do something similar to what i did, add in a variety of weapon types and I had cash rewards for hits which you could then spend at a shop for ammo types. One I liked which would be simple to do here is a dirt bomb which would cover the opponent in dirt making them have to counter it. There was also a bomb to clear dirt that didn't do damage to anyone (as a counter if you were wise enough to buy it) etc... etc... fun stuff. I could never work out the math for selecting the angle and power to hit a location though, so I may go back and revisit that game again taking some of what you taught with me.

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

      I played an old DOS game called tank wars that had a buy your ammo and some were dirt bombs of different strength. That game is a lot of fun.

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

    can you do this with javascript? it is my first language and i want to do a web game similiar to this

  • @josephwalker208
    @josephwalker208 6 років тому +3

    Hi. Your videos are great and you explain them really well. Next year just a suggestion for you to do a neural net machine learning ‘game’ of sorts. That would be great

    • @javidx9
      @javidx9  6 років тому +1

      HI Joseph, Thanks! Yes, a video on some machine learning is a good idea - I'm working on a Neural Nets one right now!

    • @ТимурАбдулов
      @ТимурАбдулов 6 років тому

      openMp OpenCl AMP Cuda ?

    • @ТимурАбдулов
      @ТимурАбдулов 6 років тому

      Maybe Rapid Packed Math ? hmm.

    • @nextlifeonearth
      @nextlifeonearth 6 років тому +1

      No CUDA. That would be useless to all the people that don't use an Nvidia GPU. In the same way AMP is Windows only (less of an issue, but Linux and Mac users would be left in the dark).

  • @LangleyNA
    @LangleyNA 6 років тому +1

    The Untouchable Reds. They were clearly better at working with the large scale of battle and not so great with individual talent. But green team lined up for red in the end, and red won the day! Yes!

    • @javidx9
      @javidx9  6 років тому +1

      lol, it was a surprisingly tense battle, i could not have scripted it any better

  • @viktorkrasovskyi7837
    @viktorkrasovskyi7837 6 років тому +1

    Amazing! But why you don't gave movement ability to your worms? :)

    • @javidx9
      @javidx9  6 років тому +2

      Thanks! Perhaps i misunderstand but the worms clearly move around the map?! They jump. Do you mean why not walk? I decided that creating two collision detection algos was too much for the videos. Having them always jump keeps the controls simple and stops the worms getting stuck on single pixels.

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

    I think this tutorial has just about everything I need to make this RTS idle game I have had in my head for the last few months. I really need to get back to coding again.

  • @florre
    @florre 6 років тому +3

    Really nice work !

    • @javidx9
      @javidx9  6 років тому

      Hey thanks Florian!

  • @AndyU96
    @AndyU96 6 років тому +2

    My greetings man, how have you been, fine I hope

    • @javidx9
      @javidx9  6 років тому +1

      Hello! I've been alright thanks! Taking a small festive season break, been working on some ideas for 'this' year. Yourself?

    • @AndyU96
      @AndyU96 6 років тому

      Myself too is fine, thanks! Can I ask you a question though, are 'classes' actually necessary for big C++ projects where classes are used? Could you have not made this worms game without using any classes, including your game engine? Are classes a must-use, or are they a definitely-should-use because they provide ease in executing certain things.
      I haven't ever made too big of a project so I never did need to use any classes so far; and because they have lots of properties (at least to my eyes), I just don't feel like getting into them.

    • @javidx9
      @javidx9  6 років тому +1

      My thoughts on this is you should only use classes where they are useful. Ultimately you never need classes - they are simply a tool to make programming a little easier - the computer does not know what a class is, and they disappear as soon as you click compile.
      They are useful because you can imply behaviour when using them, so the compiler can "automagically" create code for you. In the case of worms, I just call object.drawSelf(), instead of if(object.type == WORM) drawWorm(object); if (object.type == MISSILE) drawMissile(object); etc etc
      Classes can also help you organise larger projects, where you can encapsulate functionality in a modular way, the theory being that when the class is complete, its a reusable package of code, and it can be augmented by inheriting from the class, so you can retain a degree of compatibility.

    • @AndyU96
      @AndyU96 6 років тому

      Understood, thank you _/|\_

  • @jamesw242
    @jamesw242 6 років тому

    Really great channel. I've only got a passing interest in programming these days, but you're definitely reigniting the passion. ty

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

    I know it's several years late, but I shot a missile upwards into the sky exceeding the height of the map, and it returned an exception that states there's an access violation at line 914 in github, which test if any points on semicircle intersect with the terrain during collision.
    My solution would have been to remove any entities outside the map by setting its bDead value to true, but the missile should come back down to earth, meaning for a period of time it wouldn't be drawn on the map but need to reappear accurately during projectile motion. Is there a way to solve this?

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

      Hmmm the lines before that clamp it to within the array, so either the array is not the size it should be, or the variables defining its size are incorrect. Have you changed the dimensions of anything?

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

      @@javidx9 ah I see my mistake now. Typo, I was following along with the video and typing along, and at line 911 what was supposed to be Y was an X.
      Sorry for wasting your time, thanks for your help!

  • @cocorinow
    @cocorinow 5 років тому

    i just realized that the sprites don't scale, so when it switches to the zoomed out view, the worms turn into giants +-{:)~

  • @Jonneq
    @Jonneq 6 років тому +1

    Been looking forward to this!

    • @javidx9
      @javidx9  6 років тому

      Hi Jonathan, Cheers! I hope its not disappointing - its much quicker than my other videos

  • @loejewis
    @loejewis 6 років тому +1

    So bloody cool

  • @ТимурАбдулов
    @ТимурАбдулов 6 років тому +1

    Very helpful video thanks

    • @javidx9
      @javidx9  6 років тому +1

      Hi Timor, Thanks! I see you've some suggestions!

    • @ТимурАбдулов
      @ТимурАбдулов 6 років тому

      javidx9
      I'm just watching your code. Thank you

  • @THE16THPHANTOM
    @THE16THPHANTOM 5 років тому

    noo, you kill them all anyway? first you make them hunger games style kill each other and then you kill them even the i winners anyway by dropping bombs on them. what is wrong with you mr programmer. is there a reason for this, i just skipped to this video to see the end result.

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

      This is the nature of life: no matter if you are better than the others or not, at the end you will die.

  • @petki2010
    @petki2010 6 років тому +1

    Way to go, Sir!

    • @javidx9
      @javidx9  6 років тому

      Thanks Bura!

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

    This was thrilling!

  • @ayakakouyama6903
    @ayakakouyama6903 6 років тому +1

    Wow amazing :D

    • @javidx9
      @javidx9  6 років тому

      Cheers Ayaka!

    • @ayakakouyama6903
      @ayakakouyama6903 6 років тому

      Oh thank you so much! I am Computer Science student and I've been observing your channel for some time and I can say just one thing: keep it doing :)

  • @AfterHoursEngineering
    @AfterHoursEngineering 6 років тому +1

    Well done!

    • @javidx9
      @javidx9  6 років тому

      Thanks William!

  • @aleksandarfranc1094
    @aleksandarfranc1094 5 років тому

    Have problem. I do not find any worm(units). They do not draw when i press scroll button. There is just cross(that shows direction for moving and shooting).

    • @javidx9
      @javidx9  5 років тому

      Did you download the sprite files from the repo, you may need to change where they are loaded from

    • @aleksandarfranc1094
      @aleksandarfranc1094 5 років тому

      @@javidx9 okay i see now that these files exist. But yet i dont know how to load them in project in VS. Do i need both of them? Cause i see two spr files.

    • @javidx9
      @javidx9  5 років тому +1

      They just need to be in your project folder somewhere, dont load them into VS. You'll see some lines "= new olcSprite("worms.spr") in the worms source file or similar (im on phone so cant check precisely), just make sure those point to where the files are, and if they are in your project folder you shouldnt need to change very much

    • @aleksandarfranc1094
      @aleksandarfranc1094 5 років тому

      @@javidx9 i appreciate your help a lot. This worms project i took to be my thesis for C++ object oriented programming. So yeah i will need to know pretty much every detail hehe.
      Thanks for help. !! Will try this tomorrow.

    • @javidx9
      @javidx9  5 років тому +1

      @@aleksandarfranc1094 Cool and Thanks, its easier to discuss on Discord, so give us a shout out on there if you run into problems!

  • @villelind7875
    @villelind7875 5 років тому

    Why are you using float and not double

    • @javidx9
      @javidx9  5 років тому +1

      I dont need 64 bits of precision!

    • @villelind7875
      @villelind7875 5 років тому

      Ok, thank you! :)

  • @duyquannhan9414
    @duyquannhan9414 Рік тому +1

    All your code-it-yourself! videos are very inspiring for newcomers, what I found insane is the framerate in all your projects (300 - 500 FPS even at the final stage of the game). I'm actually trying to get into C++ for its speed, which is what I want for my game logic. Still a noob at C++ but I have 1 question, do you think your game can still be optimized for faster performance? the only way at the top of my head is parallel programming, but I've only heard of CUDA for this problem and I really don't want to mess with CUDA since it might affect the game's rendering.

    • @javidx9
      @javidx9  Рік тому +1

      Thanks, have a watch of Brute Force Processing video, I explore a variety of lesser known techniques to try and squeeze as much out of a CPU as possible. There's always ways to optimize code!

  • @aleksandarfranc1094
    @aleksandarfranc1094 5 років тому

    Unhandled exception thrown: write access violation.
    this->m_bufScreen was 0x1110112.
    I've got this message for both lines in olcConsoleGameEngine.h :
    409 : m_bufScreen[y * m_nScreenWidth + x].Char.UnicodeChar = c;
    410 : m_bufScreen[y * m_nScreenWidth + x].Attributes = col;
    anyone can help?

    • @javidx9
      @javidx9  5 років тому

      The error indicates you are creating a console that is too big for your display. In the ConstructConsole function in main(), try halving the last two values

    • @aleksandarfranc1094
      @aleksandarfranc1094 5 років тому

      @@javidx9 Bro you are KING!!! I first thought i will never get answer but i got and it works. By the way i am really preparing for this project in particular(i choose this as first one from your channel). First i gonna go through all basics for c++ and when i finish them then i am going on this project. And i just wanted to check is it working and yes it does!! Thanks for great work!!