9 Replies - 2820 Views - Last Post: 07 September 2012 - 07:42 AM

#1 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

A question for experienced XNA programmers.

Posted 27 August 2012 - 06:55 AM

I realize this is less pointed toward the actual coding of XNA, but I feel it may be helpful. Where did you learn to use XNA? Were you self taught, or was it a class? Were you in college (Or after highschool anyway.), or maybe in highschool? Or had you graduated? So far I've been completely self taught. I'm hoping to make a decent game or two to try and put on Steam or the XBLA for a dollar, to raise a bit of money for learning to make more advanced games in XNA. I've got game design down pretty well, but my development abilities are close to none. And something tells me I should change that if I ever want to be known in the game industry. So what did you do to learn XNA? And what advice would you give to those trying to learn?

Is This A Good Question/Topic? 0
  • +

Replies To: A question for experienced XNA programmers.

#2 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: A question for experienced XNA programmers.

Posted 27 August 2012 - 07:28 AM

Fair warning: Wall of text incoming, skip to bottom for tl;dr, on second thought, if you decide to skip to the bottom, then you're not ready to take any advice on learning this stuff anyway.

I am completely self taught when it comes to XNA, and most programming in general. There are some disadvantages to being self taught, but there are some benefits as well. One of the benefits is, that you can immediately start working on things that interest you, and you'll be more likely to continue learning more advanced things because you're enjoying what you're doing. A disadvantage is that you will inevitably skip over some of the more "boring" aspects, such as the theory side of development and end up making things difficult on your self later due to a lack of foundational understanding of programming design and principles.

The advice I give anyone wanting to learn to program, whether it's for games or not, is to force yourself to sit through the parts of it that you might find boring. Learn specific design patterns that are used frequently and make sure you understand the basic principles of memory management, OOP, how hardware interacts with software, etc.

With the .NET languages, and other high level languages, you don't have to be too concerned with memory management and garbage collection, but having a firm understanding of these aspects of computers will aid you tremendously in the long run.

Once you've got a firm understanding of the "basics", then it's time to challenge yourself with everything you do. If you don't find things challenging, then you're not truly learning anything and you're just going through the motions of continuously doing the easy stuff to get by. If you run into a problem, that's a good thing because it offers you the chance to learn something. Everything we do as programmers is based on things we've tried in the past and learned from. Without the drive to continue learning and challenging yourself, you're going to get tired or bored and lose interest. Once this happens, becoming a game developer is a lost cause.

The internet is an amazing tool in a developer's arsenal. You've got the collective knowledge of millions of other developers over the past 20 years at your fingertips and if you decide to not take advantage of it, then you are doing yourself a tremendous disservice. With the abundance of tutorials, code snippets, help forums, and even social networking sites like Twitter, where I often converse with the XNA MVP's from all over the world about XNA and game development related topics, you can easily connect with developers all over the entire world to discuss your projects, problems, get advice on making things more efficient, etc. You've already taken a great step in this process by joining Dream.In.Code as we have some amazingly talented and knowledgeable developers here who are more than happy to offer some time out of their day to help you learn the things that have been giving you trouble.

If you follow tutorials online, do yourself a favor and don't copy/paste the code from the tutorials, actually type them out one character at a time and think about what each of those lines of code actually does. If you can make sense of the why, then you'll more easily learn the how.

Don't be afraid to ask questions. We were all blank slates eager to learn at one time, and if you're too worried with what people will think of your abilities starting out, then you're hindering yourself by not taking full advantage of the resources that are available. Leverage the willingness for people like myself and others on this site to aid you every step of the way and you'll be much further along in a shorter amount of time than those who decide to do it all on their own because they're worried that people will judge them for their lack of knowledge.

TL;DR: Stop being lazy and read the post.

This post has been edited by Kilorn: 27 August 2012 - 07:28 AM

Was This Post Helpful? 2
  • +
  • -

#3 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 580
  • View blog
  • Posts: 1,287
  • Joined: 24-April 12

Re: A question for experienced XNA programmers.

Posted 27 August 2012 - 12:12 PM

There are classes for XNA? :-) Seriously, I haven't heard of any classes on it. But I've wondered if RB Whitiker doesn't teach a formal class in XNA, or at least C#, based on what I've read on his website. Seems like the sort of website a teacher would put up for students (extremely educational, well written, and there to do more than prove how much the author knows).

I'm known for the cities I've built with my walls of text around here. ;-) So, I'll try to keep it short.

I wholeheartedly agree with pretty much everything Kilorn said, except I may need to get a Twitter account after having heard that. But I totally agree that if you aren't strugling, you aren't learning. I spent all weekend writing XNA code that did stuff I've never done before. And I get stuck on a regular basis. I probably spend at least 10% to 20% of my time "stuck". But I'm also really good at Googling. I don't think I've ever been stuck for more than 48 hours. I post questions here every once in awhile (you can go back and check this) because I do get stuck and I'm not afraid to jump on a forum and say "I'm totally lost here. Anyone seen this before?" But 9 times out of 10 I end up being the one to answer my own questions. That's because I don't stop Googling just because I've posted the question. I also have quite a collection of computer books that I can search through, and between the two that usually gives me the answer. I'm not above buying a new book if I think it has the answer I'm looking for either.

My background is pretty much stated in my bio here. So, I'll try not to repeat what's there. But I started out programming at 12 in Basic. I studied Pascal, C, and Assembly Language in college. And I went on to basically teach myself C++ after that.

As far as XNA and C#, I didn't ever learn them. LOL It sounds funny, but I didn't. I just woke up one morning and started programming in C#. Seriously. Between working in VB.Net and my knowledge of C++ 80% of C# was just completly clear to me the first time I looked at C# code. I looked at it and went, "Dude. I already know this language."

It was really XNA that got me into C#. I do C# a little at work, but not a whole lot. Game programming gives me a reason to get better at C#, because - quite frankly - no one I work for knows enough about a computer to say whether I'm writing good C# code or bad C# code. I'm pretty much the office expert on the subject, sad to say.

So, I have no formal training in C# or XNA. With XNA, I think it's kind of expected not to know it so well. I mean the really advanced stuff in XNA is ... really advanced. I would be really suprised if anyone here knows absolutely everything there is to know about XNA.

C# on the other hand is something that I think a lot of people have formal training in and most learn before they get to XNA (unlike me who picked up C# largely just to do XNA).

Sometimes I think I should take the time to read a C# book. I'm certain that there are things that I'm doing wrong and I'm even more certain there are probably a lot of things that I could do better in my code. I would bet money, I would change a few things in my code after reading a good C# book or two.

But I've had a lot of world class teachers (in non-computer related subjects), and one thing they pretty much all say is "The best way to learn something is by doing."

I spend most of my time in XNA rather than C#. For instance, I'm trying to learn HLSL right now - which is more about game programming than it is about C#, although technically it's not C# or XNA. Oh, also I learned about ray to bounding box collisions this last weekend, which did not work the way I expected; that's an example where I spent half a day struggling to understand why my code wasn't working, even after having done bounding box to bounding box collision before.

Anyway, I know it's a weakness of mine, not having formally studied C# or even having ever read a single C# book. It's easy to get lazy or just busy working on more interesting things (like XNA) and not take the time to read a C# book cover to cover. I'm very tempted to go buy a C# 2012 book and read it cover to cover. I'm sure I would learn a lot. And going to 2012 gives me a better excuse, since I need to know what's new in 2012.

On the other hand, I think most people would say my C# code is writen on a "reasonably" professional level. Most of that comes from my experience in other langages (since I never actually learned C#). It makes it real easy to put off learning it when there's no obvious reason to learn it other then "it would probably make me a little better at it". So, when my choice is to read a book on HLSL or one on C#, I inevitably choose not to read up on C#. But even I realize I'm not writing the code to the highest standard.

As far as advice, first of all, everything Kilorn said.

I learned XNA primarily from reading. I own pretty much every XNA 3.0 and XNA 4.0 book ever written. I can't say I've read them all cover to cover, but I've read a lot of them. I usually try to do something, get stuck, and then go read the chapter on that subject in every one of those books. Sometimes I go to other books that are non-XNA, like I have a book on collisions that's more written for C++. And I was just looking at a book this morning that is largely about programming shaders (HLSL and GLSL) that again is largely written for C++.

So, I strongly advise reading every book you can get your hands on on the subject. I can't imagine learning any other way except a formal class.

I think pretty much any other advise I would give would pretty much just be repeating what Kilorn said.

This post has been edited by BBeck: 27 August 2012 - 12:18 PM

Was This Post Helpful? 2
  • +
  • -

#4 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

Re: A question for experienced XNA programmers.

Posted 28 August 2012 - 06:20 AM

Thank you both for your input on this. It sounds like I'll probably be picking up another book or two once I can. What books would you recommend? I already have Aaron Reed's XNA 4.0 book. But it sounds like this would be the most helpful method of advancing my ability. Also, I've been looking for a good method of 2D tile generation, taking a step back from 3D while waiting for BBeck's already helpful 3D tutorial. So if you now of or have any tutorials, please let me know. Google is unfruitful as of now. Thank you again for your insight.
Was This Post Helpful? 0
  • +
  • -

#5 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: A question for experienced XNA programmers.

Posted 28 August 2012 - 06:55 AM

I'd recommend Nick Gravelyn's Tile Engine tutorial series on YouTube for learning the basics of tiled level creation. It's broken up into 94 videos each roughly 10-15 minutes long. The tutorials are a bit old, they were done in XNA 3.0 I believe, but the majority of the code still works. You will however get to a point where you will find a Texture2D.FromFile method call that doesn't exist in XNA 4.0, but I'll give you the method that I created as a workaround for it:
public Texture2D Texture2DFromFile(string fileName)
{
    Texture2D texture;

    FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
    texture = Texture2D.FromStream(GraphicsDevice, stream);

    stream.Flush();
    stream.Close();
    return texture;
}



The FromFile method of the Texture2D class was removed in 4.0, but the above method does the exact same thing and is a really handy method if you ever need to load a Texture2D from a file without pulling it through the Content Pipeline.

This post has been edited by Kilorn: 28 August 2012 - 06:55 AM

Was This Post Helpful? 2
  • +
  • -

#6 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

Re: A question for experienced XNA programmers.

Posted 28 August 2012 - 08:27 PM

Thank you, I'll be following it for awhile, I'll be sure to post what I come up with. I have high hopes for this endeavor, and I'll be starting work on it tomorrow.
Was This Post Helpful? 0
  • +
  • -

#7 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

Re: A question for experienced XNA programmers.

Posted 04 September 2012 - 07:34 AM

I've gotten to the FromFile point in the video, where does this method belong? And what do I put into the OnInitialize method? I'm getting errors for all the File____ names, where do I declare them? The tutorial is going strong so far, no problems I couldn't figure out my self until now. :D Sorry for the inevitable noobiness of my ramblings. :P (Link to video.)

Edit: Derp, found the resolve button. Still don't know what to do with the OnInitialize though.

This post has been edited by ArchColossus: 04 September 2012 - 07:46 AM

Was This Post Helpful? 0
  • +
  • -

#8 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: A question for experienced XNA programmers.

Posted 04 September 2012 - 08:26 AM

void tileDisplay1_OnInitialize(object sender, EventArgs e)
{
    spriteBatch = new SpriteBatch(GraphicsDevice);

    tileCursor = Texture2DFromFile("Content/tileMapCursor.png");

    g = tileSetPictureBox.CreateGraphics();
    gr = tilePreviewPictureBox.CreateGraphics();
}



Above is my OnInitialize method. I'm sure it's going to be a little different than yours, but basically this is just where you create an instance of the SpriteBatch class, use the Texture2DFromFile method to load your cursor image, and the other two lines of code are used to instantiate the Image objects that I have placed into the tileSetPictureBox, which is what I use to display the entire tileset that I've currently loaded for the currently active layer and the tilePreviewPictureBox, which is just a larger image of the tile that you currently have selected from the current tileset.

Your code will definitely not have a tileset because the point you're at now is where I went way off of the tutorials back when I did them and starting shaping my own tile editor. You probably won't use either of those last two lines in that method, so it would probably be best for you to just remove those for now to avoid any errors while trying to follow further through the tutorials.
Was This Post Helpful? 2
  • +
  • -

#9 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

Re: A question for experienced XNA programmers.

Posted 07 September 2012 - 07:11 AM

Thank you, I've gotten to 4A 4/4, but I'm getting an error for the layer1.layer file. "Error 1 Cannot autodetect which importer to use for "Layers\Layer1.layer". There are no importers which handle this file type. Specify the importer that handles this file type in your project. E:\WindowsGame1\WindowsGame1\WindowsGame1Content\Layers\Layer1.layer WindowsGame1" I'm not quite sure on how to fix this one, and I don't see any differences in my code. Do you know a fix? Or did I just forget something? Thank you again, this place has been immensely helpful.
Was This Post Helpful? 0
  • +
  • -

#10 ArchColossus  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 49
  • Joined: 22-February 12

Re: A question for experienced XNA programmers.

Posted 07 September 2012 - 07:42 AM

Never-mind, figured it out, the files build property was set to "Compile" rather than "None."
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1