Dwarfsoft [GPA]

Forays into XNA – First Impressions

by on Mar.02, 2009, under Game Development

Print This Post Print This Post

I have started thinking about my possible development opportunities, and have decided that in order to document from 0-100mph I should start with a framework that I have never used, and a language which I have rarely used, in order to give me insight into the newbie mind. By starting from scratch I feel that the articles will cover some of those smaller aspects that we usually quickly learn and forget about. Coming from another language will allow me to document the differences from what I was expecting to what is presented and why this is so.

So, the installation of the XNA Game Studio 3.0 has completed, as has the installation of Visual C# 2008 Express Edition. The first place I was sent to was the XNA Creators Club Online. I set up my profile there, although this wasn’t really necessary.

The next step was to start looking into the XNA Game Studio Documentation. I immediately hit the Programming Guide to see what code was needed to get pictures displaying on the screen. So, seeing the short code to actually put something onto the screen I immediately set out to create myself a Sprite. (I did actually have a browse over at xnadevelopment.com as to how they did this first).

My fantastically crafted Green Block Image

My My fantastically crafted White Block

So I added the block into the project’s content area. Next, I added the following into my base class:

SpriteBatch spriteBatch;
Vector2 mPosition = new Vector2(0, 0);
Texture2D mSpriteBlock;

and loaded the sprite in the LoadContent() member function:

mSpriteBlock = this.Content.Load("whiteblock");

Finally, int the Draw member function the following needs to be added to actually draw a sprite:

spriteBatch.Draw(mSpriteBlock, mPosition, Color.White);

So, after a very short period of time, I have a sprite on screen, without a lot of code, and plenty else to go before a game is completed.

I will be attempting to build a Breakout clone in my next post: XNA in a Day.

Cheers, Chris.

:, , , ,

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!