The Jump from MMF to XNA - my experience
Author: | CYS
|
Submitted: | 13th March, 2010
|
Views: | 8769
| Rated: |
|
|
Okay, i know there's probably some hype surrounding this article but i hope you won't have too high of an expectation .
Okay, do i have the qualification to make this article? Partially. I spent a decade of life on klikking but ive only started on learning XNA for 3 months from scratch. The result - a full fledged demo featuring some rather complex mechanics (now for some shameless advertisement : http://www.create-games.com/download.asp?id=8108 ).
Of course, this article does not seek to play down any klik products. They are indeed powerful resources with a user-friendly interface for anyone looking to create games.
Why do i want to make the jump then?
1. Ease of Use
You may not believe it but from my point of view, games with complex mechanics are indeed easier to code in programming form once you get over the learning curve. You don't even need to worry about object selection or how to pause all your other events to do a inventory management system.
2. Less Limitations
Instead of working your way around alterable values A-Z, you have infinite values you can declare with any names you want. 200 active objects in MMF may slow your game down to a crawl but you can have 200 particle fly with hardly any lag at all (as long as calculations are minimal). Another great thing is that any fonts you downloaded and use will be stored in the game as SpriteFont. You don't have to worry about players not having the font in their system.
Greater Control
In game programming, the game will go through your code from top to bottom. In MMF, however, there is always the problem of conflicting events. The order of events can easily be determined in programming, but not always so in MMF.
the biggest draw?
3. MONEY!!!
I M4DE A G4ME WITH ZOMBIE WITH IT is just one of the few that makes it big despite its sub-standard quality. Games are seriously much better here in TDC than in XBOX indie games. Just download a few trials from the so-called top games and see. Of course, this is not to tell you that every xbox indie games will definitely make money. If you approach XNA with a money driven mind, refer to Muz's article : http://www.create-games.com/article.asp?id=2167
3 MONTHS!? What makes the transition so smooth?
1. Programming Background
If-else, for loop, while loop, switch, OOP. These are basics, and if you know what im talking about, you are more than ready to take on game programming. If you don't know. Don't worry, programming's not that tough. All it takes is lots of patience and dedication.
2. My experience in MMF (and other klik products)
Don't believe that jumping to XNA would be a waste of all the experience you've gathered klikking. They really help. For example, a good custom platform engine would require detectors. Right and left detectors to stop the guy when he touch a wall. A bottom detector to determine whether the guy has landed. It all works the same way.
Okay, i decided to code in XNA. What do i need?
All you need is to download 2 things:
1. Visual C# 2008 Express Edition
This is basically the IDE you'll work in. One of the best IDE around i believe. The inclusion of intellisense helps A LOT.
Grab it free here : http://www.microsoft.com/express/Downloads/
2. XNA Game Studio
Game libraries you'll need to start coding games.
Grab it free here : http://www.microsoft.com/downloads/details.aspx?FamilyID=80782277-d584-42d2-8024-893fcd9d3e82&displaylang=en
Is it free? If you're only looking to publish games on the PC, it will be COST-FREE. However, if you are looking to develop for the XBOX, you will need a premium membership - US$49 for 4 months and or US$99 for a year. Is it worth it? That's up to you to decide.
Basic Structure of an XNA Application
This section is not a tutorial on how to code a XNA application, but rather give an overview of what coding in XNA would be like.
To start off, select the Game App template. It'll give you a basic structure you need to start developing something.
The template looks something like this (with all the complexities removed) :
1. INITIALISE()
2. LOADCONTENT()
3. UPDATE()
4. DRAW()
1. INITIALISE()
The game will run this block of code when you start the game. It will do whatever necessary calculations you'll need. It will only run once.
2. LoadContent()
Similar to Initialise(), this block of code will run once at the start of the game. This is the place where you load all the textures (aka spritesheets), sounds and music you need for the entire game.
3. Update()
This block of code is where most of your codes resides in. On default, the game will loop this block of code repeatedly for 60 times per seconds (aka 60fps). Determine all your calculations and stuff here.
4. Draw()
The most important part of a game is to be able to see what you're playing. This is the part where the game will draw your sprites on the screen at the position you determine in Update(). Similar to Update(), your computer will run this block repeatedly.
Illustration of a simple task in XNA
To illustrate how this structure works, lets have an example. I hope im not getting too technical here.
I want this guy to move right when you press the right arrow keys :
1. Under LOADCONTENT()
Load a sprite of the guy simply by doing this :
Texture2D guy = Content.Load<Texture2D>(Content\\guy);
Looks complicated isn't it? It really isn't. Texture2D (like int or string) is simply a data type to store sprites information and the function that comes after that is basically a code you need to sink in your head.
2. Under UPDATE()
Write this :
keyboardstate.getState();
if(keyboardstate.isKeyDown(Keys.Right))
position = position + new Vector2(1,0);
The first line basically gets the state of your keyboard. The second statement determines whether you are pressing Right. The third statement will increase the x position of the guy (which is a Vector2 data type declared by the user).
You may not be able to memorise all these odd-looking codes even if you are good at programming but the C# express IDE has a special feature : IntelliSense which provides you with suggestions as you write your code. If you are unsure of what the exact phrase of the code is, simply look through it.
3. Under DRAW()
Write this :
spritebatch.Begin()
spritebatch.Draw(guy, position, Color.White)
spritebatch.End()
Spritebatch is basically a tool to help you draw textures on the screen. Again this is one of the many things you need to memorise. To use it, begin, draw, then end. The only thing you need to worry is the second line. It has 3 parameters - the texture (which we load the content in earlier), the position (which you calculated in Update(), and the tint (which is yep, the tint).
Troubles with coding in XNA
Of course its not like everything is easier to do in XNA. Everyone would have made the jump long ago if thats the case. Coding in XNA may give you greater control but this means you would need a longer time to do a certain thing. Here are some examples :
1. Lack of Frames
There are obviously no frames in coding the programming way. Everything basically take place in that block of code. To do everything in a systematic way, a frame structure must be custom made.
2. Lack of a Frame Editor
You won't be able to see the exact position of what you're drawing unless you code it and run it. One good way to visualise is to use a tile editor which you can find on the net.
3. Animations
The animation wouldn't play simply because there is no code like ChangeAnimation(Walking). You'll have to write methods to do that yourself. How? Use a spritesheet and move the target area manually for every frame.
4. No Midi allowed
Yeh that ancient format is not supported. Learn to say goodbye to vgmusic.com.
5. Collision
Pixel perfect collisions are no more. Sure you can still do it, but it'll be a lot to code. The simplest way is to have a rectangle mask collide with another rectangle mask.
Last but not least
Whew... that's a lot. Hopefully i gave you guys a rough idea of what coding in XNA will be like for a kliker without being too technical or long winded. Pardon my bad english too. My first language isn't English.
Finally, i would like to direct you to this website : http://creators.xna.com/en-US/create_detail
Like TDC, theres a community out there for XNA. Theres a useful tutorial there that you can start with. However, it only teaches the basics so you have to look elsewhere for other tutorials. The forums are really active and helpful too!
So guys, if you wanted to jump to the programming route long ago but is afraid to do so. Don't be. There are people out there who are very willing to help.
|
|
CYSOldie Registered 03/01/2002
Points 1523
|