This is why you need to learn to code before you go trying to make a game. More aptly put, you need to learn how to think in programming terms. And no I"m not some great developer or anything, the struggle is real for me too, but its all about sitting down, thinking things out. Programming is very logical, and when you break it down to this next sentence, you'll maybe understand a bit better. Computers are very dumb. they can do only what you tell them to do, and exactly what you tel them to do. If you get a text, your brain has sort of got its own algorithm on how to deal with that. Think about the steps, and break it down, how would you deal with getting a text. The first thing I'd do is see if I can remember where I left my phone, if not, I will use sound cues to locate it. But its more than just that, next I will need to reach for it, lower my arm down to the phone, open my hand, clamp it down on the phone. lift slightly, rotate at the elbow and shoulder to bring the phone to me. Then I locate the apply pressure to the lock button. After that, I will pub my finger about center on the screen and explore up and down until I see the notification. Then I decide if I want to reply or not.
It's just that, everything in coding is about breaking it down to the smallest steps you can. That's why we use functions, or class methods in coding, because we can take a repetitive task and make it less so by writing the code only once and then executing it. I've seen some code from BGT developers, and lot of is it messy and disorganized. Even though it is functional, things are sort of just chilling in the main loop. My way is to take each thing you want to do and write a function for it, and the main loop will be nothing but function calls. Of course, you have to find your own way, but that for me looks a lot cleaner and more organized.
Onto your actual question, what kinds of weapons do you want to have, what attributes does each of them have. Don't just say guns, abstract it further, pistols, shotguns, rifles. OK what do those guns have in common, and what are the differences. Well, first off, they all take ammo. Secondly, they fire a bullet from the cartridge as a projectile out the barrel. Third, they can each accept more than one round to fire before needing to be reloaded. OK, some differences. Pistols are usually semiautomatic, using blowback from the gas expulsion from the round to blow the slide back to trigger the ejection of one round and the clip, having constant pressure on it from the spring inside it, that will force another round into the chamber. So, it can fire about as fast as you can repeatedly press the triggers. While there are semiautomatic rifles certainly, let's focus on ones that aren't. When you fire a rifle, you generally put it up to your shoulder, take it off safe, aim and fire. To fire a new round though, you first will need to open the bolt by pulling it back, which will cause the shell to be ejected, then, due to the constant pressure exerted by the spring in the magazine, a new round will feed into the bolt carrier, which will be forced into the chamber when you push the bolt forward, and lock it into the down position. Shotguns often work the same way, but have a pump rather than a bolt, you fire a round, pull the pump which forces a shell out, push the pump which forces one in and fire again. Now, we have things that don't fit into those categories and you will need to consider if you want those outliers or not. Things like revolvers which can and cannot be semiautomatic. There are older revolvers that you have to cock the hammer back each time you want to shoot, and newer ones where there's a double action, so that by you pulling the trigger, you're exerting force to cock the hammer back, then at the end of the pull, the mechanical device that is pushing the hammer back moves out of its way, allowing it to slam forward again, using its spring tension to make it strike the primer of the round that's lined up with it to cause the powder to ignite. You also have breach loading shotguns, meaning that they take only one round, you pull a lever, the barrel and receiver tip apart from each other, you insert one round into the chamber, then push them together again and you can fire.
SO what can we put into code from this. Well, Each weapon is going to need a clip size, and a current ammo in clip. Those in BGT would be uints, since they should never be negative. The clipsize could also be a const if you didn't want to code a class called weapon, and create each object from that class. You could really go deep by creating a weapons class, then, derived classes of automatics, semiautomatics, non-automatics and so on, but its not required. Also, what else can we see that we need. A boolean to say the thing is firing, a boolean maybe to see if the safety is on if you want to simulate that for some reason. A bool to say whether its reloading or not, and it goes on from there.
Facts with Tom MacDonald, Adam Calhoun, and Dax
End racism
End division
Become united