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
Your teaching videos and programming skills are equaled by your commentator abilities ! ^^ It was really entertaining to listen to :)
Thanks Carmen! - I dont think i'll give up the day job to be a sports commentator just yet however :D
@@javidx9 That explains the clarity and interest you are able to carry in your voice! A+ content.
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. :)
Hey Sedit, yeah a discord battle royale would be interesting!
NOOOO, GREEN TEAM LOST :(
WOOOO GO REDS!
Absolutely brilliant work!
Cheers Joel!
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! :)
Thanks Steve! Such a nice thing to say! Have a good Christmas too!
That is mega cool. I'm going to have to get back into programming.
Good stuff Davstr, and good luck!
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.
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.
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.
can you do this with javascript? it is my first language and i want to do a web game similiar to this
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
HI Joseph, Thanks! Yes, a video on some machine learning is a good idea - I'm working on a Neural Nets one right now!
openMp OpenCl AMP Cuda ?
Maybe Rapid Packed Math ? hmm.
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).
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!
lol, it was a surprisingly tense battle, i could not have scripted it any better
Amazing! But why you don't gave movement ability to your worms? :)
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.
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.
Really nice work !
Hey thanks Florian!
My greetings man, how have you been, fine I hope
Hello! I've been alright thanks! Taking a small festive season break, been working on some ideas for 'this' year. Yourself?
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.
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.
Understood, thank you _/|\_
Really great channel. I've only got a passing interest in programming these days, but you're definitely reigniting the passion. ty
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?
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?
@@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!
i just realized that the sprites don't scale, so when it switches to the zoomed out view, the worms turn into giants +-{:)~
Been looking forward to this!
Hi Jonathan, Cheers! I hope its not disappointing - its much quicker than my other videos
So bloody cool
Very helpful video thanks
Hi Timor, Thanks! I see you've some suggestions!
javidx9
I'm just watching your code. Thank you
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.
This is the nature of life: no matter if you are better than the others or not, at the end you will die.
Way to go, Sir!
Thanks Bura!
This was thrilling!
Wow amazing :D
Cheers Ayaka!
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 :)
Well done!
Thanks William!
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).
Did you download the sprite files from the repo, you may need to change where they are loaded from
@@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.
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
@@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.
@@aleksandarfranc1094 Cool and Thanks, its easier to discuss on Discord, so give us a shout out on there if you run into problems!
Why are you using float and not double
I dont need 64 bits of precision!
Ok, thank you! :)
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.
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!
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?
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
@@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!!