-
code needed for 2d game
i am making a 2d game and i have all the nessicary things for the game accept the shooting function, i am new to C# programming and am using XNA for the game
i need a projectile class that shoots a bullet, sets the max bullet to 5 on screen, and also gets the charPos to spawn the bullet. i am not sure how to do it as i am moding the platform1 example game that comes with XNA so the code is hard to follow and things are being called all over the place rather than being declared at the start
the function does not need ammo or a damage rating as the bullets are one hit kills and unlimited
can anyone help or have done this for an XNA game before?
-
Show us what you have tried and we can go from there. We do not need the entire game posted. Post the projectile class that you attempted to create.
-
Also, I'd like to add that while their code may be hard for you to follow at first, if you are going to use it as a starting point, dedicate some time to studying it and learning what the code already does. It's vital that you have a sort of conceptual overview of the flow of the code, and have at least a basic understanding of what the code is doing. Trying to make changes without having at least some understanding of how the code is set up is a recipe for disaster -- it would be like trying to perform surgery without knowing where various organs were or what they do.
There's no real alternative; when you're working with someone else's code, you need to spend some time familiarizing yourself with their code and how it works. Only when you understand how it works can you really understand how to change it. This isn't to say you need to understand every little detail, but you should at least have a basic grasp of the code. Hopefully the example apps are well-commented.
I know it's kind of a boring step, and people want to jump in and create their ideas quickly, but if you don't build your code on a solid foundation of understanding, you're going to end up with buggy or downright nonfunctional code, and it's going to be a frustrating nightmare. Study the existing code, learn what it's doing, learn how it works first. Once you feel comfortable with the existing code, it'll be a lot easier to add new code into the mix.