Welcome to my XNA tutorial site
Look around, learn, experiment and ask questions :). If you have a request for a
tutorial, just let me know.
Tutorials
Drag and drop with snap to tiles If you need to create a tile-based editor, or for some other reason need to show selected tiles based on the mouseposition – here’s some code to help you do that. The code also walks you through the math, so you can implement it yourself :). In only 277 lines of code it gives you a code sample for dragging and dropping onto a grid, displaying where you are about to drop.
Easily add drag and drop to your XNA gameThis is a complete controllerclass which is created for easy inclusion in your game. If you need drag and drop it doesn't get much simpler :).
And if that isn't enough, you can take the code apart and tinker with it to your heart's content
And if that isn't enough, you can take the code apart and tinker with it to your heart's content
Pointing and moving towards a targetA complete step-by-step explanation of vectors, how to get the direction from one object towards another and how to move towards that object while making an image point in that direction.
Saving and loading data in a windows game A short introduction to saving and loading your gamedata in XNA using the built-in .net xml serialization. This only works for Windows games, not XBOX nor Windows Phone 7. But if you (like me) mostly code windows games, it’s very easy to use. The tutorial comes with a readybuilt helperclass “SerializationHelper” to assist with saving and loading data
Rolling dice in XNA A complete code sample showing how to create rolling dice with random results. Includes a little "Die" class you can reuse and customize for your own games.
Loading small games dynamically This is a five part tutorial series on creating an XNA Arcade, where a lot of games are presented in a menu for the player to pick from. When selected, the subgames are loaded for play, and the player can exit the subgame and return to the menu at any time. With complete tic-tac-toe subgame sample
Optimizing rendering of non-tilebased items This tutorial will give you an understanding of how you can optimize what your graphics adapter spends its time rendering, by splitting your gameworld into a grid where each little rectangle stores a reference to the items that are visible in it.
Creating a reusable menu from scratch This step-by-step tutorial guides you through creating a control which extends the DrawableGameComponent into a control which lets you choose from a menu implemented as a cut-out from a picture. The tutorial covers:
best-practices when overriding, how to send parameters to a superclass's constructorimplementing gradual movement, ensuring values set in a property are valid.
best-practices when overriding, how to send parameters to a superclass's constructorimplementing gradual movement, ensuring values set in a property are valid.
Simple platformer game in XNA - a tutorial A complete walkthrough of creating a simple platformer in XNA.
Also covers some Object Oriented problems you may run into and the Clean Code philosophy.
So far the two first installments are in place
Also covers some Object Oriented problems you may run into and the Clean Code philosophy.
So far the two first installments are in place
Spice up your level setup This is a complete tutorial where we walk through all the steps of creating a helperclass which can move a collection of objects from one position to another.We will use this to setup the board for the Simple platformer game so there is a new animation every time the game starts.We wil be looking at interfaces, lambda expressions, Funcs.
Code and tools
Random robot and spaceship generator This is an XNA implementation of Dave Bollinger's Pixel Robots and Pixel Spaceships. Using only a few lines of code you can generate endless numbers of unique enemies at runtime.
Random maze generation in C# This is a short write-up on the algorithm for generating random mazes. The code has been implemented for you in C#. The code includes a complete MazeGenerator class for you which will generate mazes of the size you specify. As a bonus, I've included code to generate these fun little animated GIFs as well :).
Manipulating doublearrays using extension methods A collection of extension methods for rotating or flipping the values in double-arrays (arrays of the type: "int[,] myArray"). Can be helpful for your own games, if you have to rotate a map or flip it.
Taking screenshots in xna Two extensionmethods for the GraphicsDevice class, so you can easily add the possibility for screenshots to your games
Shuffling lists in C# – an extensionmethod An extensionmetod "List<t>.Shuffle()" for randomizing any List<T>. Easy shuffling of cards, treasures, tiletypes, etc.
Map generation in XNA A small application for generating maps in XNA. Stores the maps as TXT files so they are reusable using any framework. Bonus! extensionmethods for doublearrays.
Games
Small Space Shooter A small space shooter inspired by a set of graphics from opengameart.org, where I am only using that set of graphics.
Resources
Free XBox button graphics for your game
A set of XBOX controller buttons in varying sizes as PNGs for free to use in your own games. No royalties, no ifs, buts or anything - go ahead
read more...
A set of XBOX controller buttons in varying sizes as PNGs for free to use in your own games. No royalties, no ifs, buts or anything - go ahead
read more...