Request a tutorial.

  • (5 Pages)
  • +
  • « First
  • 3
  • 4
  • 5

60 Replies - 52583 Views - Last Post: 14 September 2015 - 03:34 PM

#61 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 765
  • View blog
  • Posts: 1,825
  • Joined: 24-April 12

Re: Request a tutorial.

Posted 14 September 2015 - 03:34 PM

Welcome to the forum!

I recommend checking out the Tutorials section for game programming tutorials here. You might start with this one

http://www.dreaminco...s-and-textures/

If you are fairly comfortable in C#, XNA is pretty easy. XNA is different than Unity in the way it works, substantially different.

You probably want to start with more simple tasks first, rather than jumping into doing a 2D platformer for your first project. Start by learning to draw a few sprites on the screen. Then learn how to move them using the keyboard or game controller. Then learn about the different types of collision detection. Learn about sprite batches and animating sprites using them.

You can probably find tutorials for XNA 4.0 or MonoGame on YouTube for 2D side scrolling platformers when you're ready.

Also, you can check out my stuff at VirtuallyProgramming.com although I only have a couple of things that are not 3D, but there's a lot of XNA stuff. Also, in my links section I have a link to RB Whitaker's website and he does a lot of 2D XNA stuff that you should definately check out.

Basically the way XNA works is that you select a template to create your program under File=>New=>Project and select "Windows Game" for a game that runs on Windows. The template will create a bunch of stuff for you. It will create a Program.cs file that you normally don't have to mess with at all. And it will create a Game1.cs file which is where you will write your code. You can call your own .cs files from Game1 if you like.

There are also two projects created. One is your main project where the cs files I just mentioned are at. But the other is a Content project where you need to add any textures for sprites and other art files such as sound files. XNA will compile the art files in the Content project into its own internal format (.XNB) automatically.

If you look through Game1.cs you will see several methods/functions that you are expected to change in order to make your game. The Initialize() method is where you put any code you want to run when the game first starts other than loading art assets. The next method is the LoadContent() method which will also run once at startup, but it is mainly for loading your art assets like the textures for your sprites and sound files and 3D models. The UnloadContent() method is where you remove art assets from memory, but I've never seen anyone use it for anything other than one time. So, basically forget about it for now.

After that, the game loop starts running. As I explained in my "Learning 3D Game Programming" road map post, the game loop is much like old film cameras. You can read that post for more detail, but basically roughly 60 times per second it goes through this loop.

One pass through the loop is called a "frame". The Update() method is where you put all your game code. This gets called by the loop every frame or about 60 times per second. Basically, all your code that doesn't draw stuff to the screen goes here or is called from here. The Draw() method is also called every frame or roughly 60 times per second.

In the Draw() method, you are drawing one screen or one "frame". If you've ever seen those flip books where you flip through the pages to do animation, that's basically what you're doing here; you're drawing one screen and then the next time the loop calls the Draw() method you will draw the next screen. And if you slowly change things between frames, the person watching the screen will think they are seeing animation. It will create the illusion that things are moving. You're really drawing still images, but by drawing them 60 times a second, any changes will appear as animation.

Draw() and Update() work very closely together. Update() is where you have all the code that changes everything every frame. And Draw() is where you have all the code to draw the current scene, or frame of the scene.

XNA is very "open ended". It doesn't do much of anything for you the way Unity does. And you can mostly do things the way you choose to do them.
Was This Post Helpful? 0
  • +
  • -

  • (5 Pages)
  • +
  • « First
  • 3
  • 4
  • 5