Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

Newbie XNA Game Programming Thread: One SpriteBatch Per Customer Please!

The Newbie XNA Game Programming Thread

So you can code more or less, you've always wanted to make games, but you've never really taken the time to learn how? You've come to the right place.

XNA is an API that helps you write games that can run on Windows or on the Xbox 360. XNA code is written in C#, although advanced programmers writing their own hardware shader code will use HLSL. If you know C you can pick up C# easily, and you never really have to learn HLSL.

If you've instead come to read about and discuss published, playable XNA games (a.k.a. Xbox Live Community Games) you are in the wrong place and should probably go to this thread instead.

If you are an XNA developer working on a project you plan to sell for money, and you're looking for programming help, you should probably go to that same thread. If you post here for help, please be willing to share enough about your question that everyone can learn from the answer.
Proposed thread rules follow:
Spoiler:

Getting Started 1: Software and Optional Services
Spoiler:

Getting Started 2: Concept Overview
Spoiler:
XNA Creator's Club Meta GamerTag List
Are you playing with multiplayer code? Interested in finding other players to test your code with? Add people from this list. Also there is a MetaTag you can review on your 360.
NOTE: For this to be useful, you must have a Premium XNA Creator's Club Membership *and* either a LIVE Silver membership (to connect from PC) or a LIVE Gold membership (to connect from your 360.)
Send a Friend Request to: A PA XNA Coder
If you're looking for people to test games with, find A PA XNA Coder in your friend list, view profile, and view A PA XNA Coder's friend list. Browse that list and find someone who is online, and send them a message or an invite!
Current members:
  • Michael Spencer - mspencer
Project Directory
  • Minotaur
    • Description: 2D top down game. A random maze is generated. You start from the top left corner, and try to navigate to the bottom right corner. Also in the maze is a minotaur monster who starts at the bottom right corner and tries to find and kill you before you escape.
    • Users and Builds:
      • mspencer
        • http://mspencer.net/PA_XNA/Minotaur_v1.zip -- I threw this together in about three hours, mspaint-tastic graphics and all. Super basic, code isn't even commented. It's an embarrassment, but it works. Arrow keys or WASD to move, esc to exit. The game never exits until you press esc, so I would say if you reach the exit square (or you die on the exit square) then let's say you won.
        • http://mspencer.net/PA_XNA/Minotaur_v2.zip -- Updated a bit to visualize how the minotaur handles "scent trails" in the maze. Spacebar to toggle visualization on and off.
        • http://mspencer.net/PA_XNA/Minotaur_v3.zip -- I cheated and borrowed someone else's priority queue code. I'll go back and write my own. But I implemented some crude pathfinding code not for the minotaur but for the maze generator and for the beginnings of "mouse control." Added controls: Y, U, I, and O toggle some things on and off. Numpad + and - resizes the maze. See in-game text for more.
  • Cheater Cheater Pumpkin Eater
    • Description: a MULTIPLAYER (LIVE or System Link) top down game that hasn't been designed yet. The basic code is all user controlled with no cheats. Your mission, should you choose to accept it: customize the project so it lets the user cheat. Build an aimbot, display secret information, improve your player's reaction time, lie about your player's health, whatever you like. Note that you MUST use the same project identifier as everyone else, or else our games won't be able to connect to each other.
    • Users and Builds:
  • BulletHell
    • Description: 2D top down game. A cannon is shooting bullets at you. Try to avoid them. Mostly a test-bed for different algorithms for firing bullets at players.
    • Users and Builds:

. . . continued . . .

mspencer on
MEMBER OF THE PARANOIA GM GUILD
XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
«1

Posts

  • mspencermspencer Registered User regular
    Getting Started 3: C# Language Primer
    Spoiler:

    Getting Started 4: XNA Code Overview
    Spoiler:

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • iTunesIsEviliTunesIsEvil Registered User regular
    Damnit, now I have to reinstall VS2008. :P

  • mspencermspencer Registered User regular
    Whew. Still not done with the OP, but getting closer. Still need to finish the XNA code overview.

    I'd love to get some feedback though, as I'm scared I'm jumping all around different skill levels. I might be in danger of confusing and driving away the very people I'm trying to help.

    Maybe I'm harping on the garbage collector a little too much. I figure that whole lesson does double duty, helping people better understand how objects are created and used. Maybe I'm just confusing people though.

    I don't really have the real POINT of the thread -- here's some recipes for adding your own code to a blank project -- done yet, but so far what do people think?

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • Smug DucklingSmug Duckling Registered User
    This is amazing. I'm getting inspired to switch off my other projects and give this XNA thing a whirl.

    smugduckling,pc,days.png
  • bowenbowen Registered User regular
    Any chance of you getting some Managed DirectX info up there?

  • Michael HMichael H Registered User
    Great OP, it's obvious you've put a lot of time into this. Hopefully it will become a well-used resource. Thanks!

  • mspencermspencer Registered User regular
    bowen wrote: »
    Any chance of you getting some Managed DirectX info up there?

    I've never done anything with managed directx, but I'll look into it.

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • bowenbowen Registered User regular
    mspencer wrote: »
    bowen wrote: »
    Any chance of you getting some Managed DirectX info up there?

    I've never done anything with managed directx, but I'll look into it.

    :^: that'll take your op from the "best" I've read so far, to "fucking amazing" in terms of XNA dev.

  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    I am tempted to write a simple game to give XNA a serious whirl, and finally learn that C# proper.

    No idea when at the moment though as I have a lot of work to catch up on. :lol:

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • mspencermspencer Registered User regular
    bowen wrote: »
    mspencer wrote: »
    bowen wrote: »
    Any chance of you getting some Managed DirectX info up there?

    I've never done anything with managed directx, but I'll look into it.

    :^: that'll take your op from the "best" I've read so far, to "fucking amazing" in terms of XNA dev.

    I just took a break to start reading about MDX. Wikipedia says MDX 2.0 was cancelled while still in development, superceded by XNA. Maybe there could be some info about MDX 1.1, but I don't know if it makes sense.

    Or did I find the wrong thing? Were you referring to something else?

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • bowenbowen Registered User regular
    Hmm I had assumed the MDX 2.0 was part of XNA, but, still a different beast that probably requires it's own documentation and all that in it's own right.

    Let me look it up.

    Edit: Nevermind, yeah XNA is MDX 2.0 with some more fluff added on top of it. I didn't realize that all the classes got rewritten into the c# and I thought there was a lot of extra steps to do anything other than "behind the scenes" game logic with XNA.

  • TofystedethTofystedeth veni, veneri, vamoosi Registered User regular
    How easy is XNA/C# to pick up for someone who learned programming on C++ and was decentish at it, but hasn't touched it in 5ish years, but now works a fair amount in Python?

    steam_sig.png
  • bowenbowen Registered User regular
    Easy. Really easy.

  • TofystedethTofystedeth veni, veneri, vamoosi Registered User regular
    [burns]excellent[/burns]

    steam_sig.png
  • bowenbowen Registered User regular
    Like, you are exactly the kind of person they made C#/XNA for. Someone who's a hobbyist and doesn't want to know how to do the ins and outs of DX surfaces and all that garbage. I mean trying to switch an old app from full screen to windowed mode proved to be so much of a hassle my friend rewrote it for SDL instead.

  • TofystedethTofystedeth veni, veneri, vamoosi Registered User regular
    Oh, mspencer, what I've read through of the OP is great, but you do Blender an injustice by referring to it only as a mesh editor.*

    Man I wish I had any skill at art. Blender was so fun to mess around with. Even bought me the Blender book a few years back.

    *Though I understand calling it such as for the purpose of learning simple XNA stuff you won't really need any of it's other features.

    steam_sig.png
  • mspencermspencer Registered User regular
    Indeed. (Since you brought it up: in your class constructor just set this.graphics.IsFullScreen = true or false as you like.)

    OK, I didn't expect it to take a DAY AND A HALF but both sections of the OP are done.

    I think I already said this, but my hope is that this isn't just a document plus comments, but a living resource. People who are NOT ME can say "I want to play with making a game do THIS" and start tinkering and zipping up daily builds and posting about them.

    I really don't want to be the ONLY person doing this, so I'll start. I'm curious about how to make bullet hell games, or at least aiming algorithms for slow-moving bullets or missiles. So I want a game where the player moves around and dodges a stream of bullets, so I can play with bullet aiming algorithms.

    So I think I'll start by making a player that slides around the screen, make a little stationary ball at the upper right corner that shoots things at a fixed 45 degree angle with no aiming intelligence, make a little bullet thing, and see if I can make everything animate at once. And then detect collisions.

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    mspencer wrote: »
    I really don't want to be the ONLY person doing this, so I'll start. I'm curious about how to make bullet hell games, or at least aiming algorithms for slow-moving bullets or missiles. So I want a game where the player moves around and dodges a stream of bullets, so I can play with bullet aiming algorithms.

    So I think I'll start by making a player that slides around the screen, make a little stationary ball at the upper right corner that shoots things at a fixed 45 degree angle with no aiming intelligence, make a little bullet thing, and see if I can make everything animate at once. And then detect collisions.

    This is what I was going to work on, a tone-downed version of a shooter game concept I have. :lol:

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • PhyphorPhyphor Registered User regular
    Bullet hells are all about patterns in the firing of the bullets.

    You can often create a basic one just by having a bullet spread from several different sources that are moving and/or rotating

  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    Yeah, it's simple in execution with classes of shots and some path shapes that can be applied (for shots and mobs alike) and the work is in the content creation really. Making an intricate boss pattern that is just-the-right-amount challenging and interesting seems like more work to me. :)

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • PhyphorPhyphor Registered User regular
    Yup, once you get the basic weapon types working all the actual work is in the level design, I'm actually working on a shooter myself ATM (though not doing level design)

  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    Looks like this may be a good project for open / educational development. :^:

    Should... do... work... first...

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • bowenbowen Registered User regular
    Man you fuckers are going to make me make a stupid free-style mmo where you can chuck cubes at each other, I just know it.

  • TofystedethTofystedeth veni, veneri, vamoosi Registered User regular
    One thing that's been kind of sitting in the back of my mind is making a space based version of the battle-navigation puzzle from Puzzle Pirates. Like, Puzzle Pirates + Master of Orion 2.

    steam_sig.png
  • TofystedethTofystedeth veni, veneri, vamoosi Registered User regular
    bowen wrote: »
    Man you fuckers are going to make me make a stupid free-style mmo where spheres can chuck cubes at each other, I just know it.

    Fix'd for the game my artless self would make.

    steam_sig.png
  • PhyphorPhyphor Registered User regular
    Spheres? That's fancy graphics Mr Artist

  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    Yeah, you got like, shading and shit in there!

    Quit looking down on us circle folk.

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • bowenbowen Registered User regular
    I'd have made a triangle that shot cubes. Fuck spheres, that's way too much art/math involved for me.

  • PhyphorPhyphor Registered User regular
    bowen wrote: »
    I'd have made a triangle that shot cubes. Fuck spheres, that's way too much art/math involved for me.

    How can you have too much math?

  • bowenbowen Registered User regular
    Generally with light/diffuse mapping. Unless it calculates it for me now. I hated doing that shit in OGL, I even wrote a program on my calculator to do some quick diffuse mapping calculations.

  • InfidelInfidel It's not Infidel, it's INNNNNFIDELRegistered User regular
    Ah, yes.

    Using the maths = good.

    Hand calculating the maths = oh god shoot me.

    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Phalla discussion and Secret Santas :: PhallAX 2013
    Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • bowenbowen Registered User regular
    Why I didn't write a similar function into my code I'll never know, but hey, I was only 14, what the shit did I know.

  • Michael HMichael H Registered User
    bowen wrote: »
    Why I didn't write a similar function into my code I'll never know, but hey, I was only 14, what the shit did I know.

    "Man, if only there was some way to compute all of these values... some kind of processor unit, perhaps centrally located, that could do all this for me, as if I had a program of some kind. Oh well."

  • MegatinMegatin Registered User regular
    That is one excelent OP. I might have to start messing around this weekend.

  • bowenbowen Registered User regular
    Michael H wrote: »
    bowen wrote: »
    Why I didn't write a similar function into my code I'll never know, but hey, I was only 14, what the shit did I know.

    "Man, if only there was some way to compute all of these values... some kind of processor unit, perhaps centrally located, that could do all this for me, as if I had a program of some kind. Oh well."

    I'm going to see what I can whip up this weekend.

    And yeah, it's probably because I just got my graphic calculator for my calculus class, for my senior year. Good ol' Basic.

  • mspencermspencer Registered User regular
    Alright, play by play narrative for project BulletHell.
    Spoiler:

    Code so far: http://mspencer.net/PA_XNA/BulletHell_v1.zip

    There's no game to it, just a stream of bullets. But the framework I built should let me use any bullet size and speed, and even different textures. Since they're balls maybe I should make them spin. Maybe I should add some extra textures -- a sawblade, that 4chan smiley, a soccer ball, a baseball, etc.

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • mspencermspencer Registered User regular
    Continuing with BulletHell.
    Spoiler:
    Code so far: http://mspencer.net/PA_XNA/BulletHell_v2.zip

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • Michael HMichael H Registered User
    Hmm... that's unexpected. You mentioned needing VS2008 in the OP, but I assumed that meant "VS2008 or later". I just downloaded XNA and got told that it needs 2008 specifically... I have VS2010 Pro.

  • mspencermspencer Registered User regular
    Ah, sorry about that. Yeah, I'll make more of a point about that in the document. I believe you can have both installed on one system though. I've never used 2010 so I'm not sure what troubles you might run into if 2008 tries to register file associations previously held by 2010.

    MEMBER OF THE PARANOIA GM GUILD
    XBL Michael Spencer || Wii 6007 6812 1605 7315 || PSN MichaelSpencerJr || Steam Michael_Spencer || Ham NOØK
    QRZ || My last known GPS coordinates: FindU or APRS.fi (Car antenna feed line busted -- no ham radio for me X__X )
  • Michael HMichael H Registered User
    Oh that's not your fault, I'm just surprised that they don't have XNA capable of working with either environment.

Sign In or Register to comment.