Thread: code needed for 2d game

  1. #1
    Registered User
    Join Date
    Feb 2010

    Unhappy 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?

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    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.

  3. #3
    Registered User
    Join Date
    May 2003
    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.
    Last edited by Cat; 02-10-2010 at 05:48 PM.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 'Business code' vs 'Game code'
    By VirtualAce in forum A Brief History of
    Replies: 15
    Last Post: 01-09-2007, 03:33 AM
  2. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  3. craps game & dice game..
    By cgurl05 in forum C Programming
    Replies: 3
    Last Post: 03-25-2006, 07:58 PM
  4. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  5. Game of Craps Source Code
    By Miles in forum C Programming
    Replies: 5
    Last Post: 02-17-2002, 01:46 PM