Thursday, April 30, 2009
Appologies...
-----------------------------
Proud member of Dream.In.Code
-----------------------------
Proud member of Dream.In.Code
Wednesday, April 29, 2009
What I'm going to try...
Tuesday, April 28, 2009
Help getting you started...
Proud member of Dream.In.Code
Monday, April 27, 2009
Hi there..
Proud member of Dream.In.Code
Sunday, April 26, 2009
Expect the unexpected...
-----------------------------
Proud member of Dream.In.Code
Saturday, April 25, 2009
The next tutorial...
Friday, April 24, 2009
About classes...
So, sorry...
-----------------------------
Proud member of Dream.In.Code
Wednesday, April 22, 2009
Your first C# program
About the tutorial...
-----------------------------
Proud member of Dream.In.Code
Tuesday, April 21, 2009
What is next...
-----------------------------
Proud member of Dream.In.Code
Monday, April 20, 2009
What's up for tomorrow
-----------------------------
Proud member of Dream.In.Code
Saturday, April 18, 2009
Making posts...
-----------------------------
Proud member of Dream.In.Code
Friday, April 17, 2009
C# Basics
Some objects are considered types. These are fundamental objects that are used to build other objects.
Here is a short list of some of them:
- int represents an integer like 1847 or -12784
- float represents a floating point number like 1.29847 or 3.14159
- bool represents a Boolean value that can be true or false
- char represents a character like A or Z
- string hold many characters of data like "Hello, my name is Bob!"
Objects are stored in variables. For example, suppose you wanted to store an integer. You would declare it like this:
int myInteger;
I think that is enough for today. Check back tomorrow and I will try and have a tutorial about how you would go about creating a simple C# program.
-----------------------------
Proud member of Dream.In.Code
Thursday, April 16, 2009
Introduction to Object-Oriented Progamming
So what does that mean to a programmer? In your applications you break everything that you are trying to model into objects. Say you are trying to write a program that models cars. Think about a car. What are some of things that are common to all cars? Well, cars all have a manufacture like Ford, Buick, Toyota. Cars all have colors. Cars all have a number of gears. Cars can be standards or automatics. These are just a few of the common things about cars. So why is this useful? Well, if you wanted to model a car you need to understand the attributes of cars. Attributes are used to differentiate objects.
Cars also have behaviours. For example you can turn on or off the ignition. You can change gears. You can change speeds. You can steer. Why is that important? When modelling an object you will want the object to perform different actions. These actions are called methods.
So how would you go about implementing this in your programs? You would use what is called a class. A class is used to define the attributes and methods of an object. You can think of a class like a template. When you need a new object you use a class to make the object.
That is a lot to take in so that is all I will be writing about today. Tomorrow I will show you how you would go about creating a class.
-----------------------------
Proud member of Dream.In.Code
Wednesday, April 15, 2009
Getting started with C#
In this tutorial series I will be using Visual C# 2008 Express Edition. There was a 2005 edition but it has been discontinued. Not all of the code will work in Visual C# 2005. It is always a good idea to use the latest version of software anyway.
Tomorrow I will help you get started with C#.
Proud member of Dream.In.Code
Tuesday, April 14, 2009
Tutorials on C#
Monday, April 13, 2009
My new blog...
Role-Playing Game Project http://xna-rpg.blogspot.com
Change in plans...
Look for the new blog shortly and the first of my tutorials about C#.
Saturday, April 11, 2009
Introduction to Tiling
For a simple tile map, the best thing you can do is make an array of integers to the index of like this:
int[,] map = new int[,]
{
{0, 0, 0, 0, 0, 1, 0, 0, },
{0, 0, 0, 0, 0, 1, 0, 0, },
{1, 1, 1, 1, 1, 1, 1, 1, },
{0, 0, 0, 0, 0, 1, 0, 0, },
{0, 0, 0, 0, 0, 1, 0, 0, },
{0, 0, 0, 0, 0, 1, 0, 0, },
};
You can think of the 0's representint the first tile that is say a grass tile, 1's represent the second tile that is say a road tile. , the 2's would represent another tile, and so on.
static int tileWidth = 32;
static int tileHeigh = 32;
It would be a good idea to create two variables to hold the height and width of the tiles you are going to use like this:
Before you can draw something you would have to load the Textures in the LoadContent method. I'm not going to go into that, this is just a quick introduction (because I still haven't found tiles I like). But I will assume that there is a list of tiles that was loaded in the LoadContent method. This is how the list was defined:
List<Texture2D> tileList = new List<Texture2D>();
So, how do you draw the map?
In XNA you will do that in the Draw method. You would do something like this:
int mapWidth = map.GetLength(1);
int mapHeight = map.GetLength(0);
int index;
spriteBatch.Begin();
for (int y = 0; y <>
{
for (int x = 0; x <>
{
index = map[y, x];
spriteBatch.Draw(tileList[index],
new Rectangle(x * tileWidth,
y * tileHeight,
tileWidth,
tileHeight),
Color.White);
}
}
spriteBatch.End();
Looking at the code you might be thing: He's got the x and y backwards! Truth is typically in math coordinates are writen (x, y) so are screen coordinates. For our tile engine to work we have to reverse them to (y, x).
The drawing code works this way. I get the size of the map that I will be drawing and define a variable to store the index of the texture in our list.
Then I call spriteBatch.Begin(). If you are going to draw Texture2Ds you have to put the
drawing code between a spriteBatch.Begin() and a spriteBatch.End().
I set up two for loops. I start at coordinate (0, 0). Then I go through the rows of the array and draw the tile using the spriteBatch.Draw method. There are many overloads to the Draw method. I just used the first one. The parameters are:
- the texture to be drawn
- the destination rectanlge on the screen
- the tint color
The texture is easy. It is just the texture from the list indexed by the index from the tile map. The destination rectangle is what needs explaining. The destination rectangle is a rectangle whose x and y coordinate will go someting like this: (0, 0), (32, 0), (64, 0), (96, 0), ... for the first row and (0, 0), (0, 32), (0, 64), (0, 96), ... for the first column.
The second row would go like this (32, 0), (32, 32), (32, 64), (32, 96), ...
The second column would go like this (32, 0), (32, 32,), (32, 64), (32, 96)...
You will see better when I manage to get the tutorial for the tile engine working.
The tint color allows you to tint your textures. Typically you don't want any tint so you put in Color.White. That is the basics of how tile works. There are a few more concepts to be tied in. Such as preventing the map from scrolling off the screen, only drawing the portion of that map that is visible and scrolling the map in general.
Friday, April 10, 2009
What's up...
Look for the tutorial maybe on the 11th or the 13th at the latest. I am not going to be doing anything on the 12th as it is Easter.
Thursday, April 9, 2009
Introduction to XNA 3.0
For Windows games you must meet the minimum requirements for Visual C# 2008 Express Edition and you must have a graphics card that supports Pixel Shader 1.1 or better. Most modern ATI and nVidia graphics cards support Pixel Shader 1.1 or better. If you do not have a card that supports Pixel Shader 1.1 you really can not program in XNA.
In XNA you have the Content Pipeline. It is used to import a wide variety of content to your project. For the purposes of what I will be doing all you have to worry about is Texture2D, which will be used for tiling and sprites and sound files. Eventually there will be some XML files but I am going to make custom importers, processors and exporters to compile them into .XNB files. Otherwise the XML files could be edited by others playing your game and they can change the content of your game.
XNA has two methods that are called often. They are the Draw and Update methods. In the Update method you process thing like input, collisions, moving objects, etc. In the Draw method you draw your scene. The rate at which they are called can be changed programmatically.
Tomorrow, or the next day, I plan on posting a tutorial on how to do basic tiling. So look for that in the next do or so.
Wednesday, April 8, 2009
Really good news!
Next tutorial on RPG
Today I will be posting a new tutorial on the Role-Playing game. In this tutorial I talk about how you could go about implementing the different modes of play in the game in such a way that you can easily edit and change the modes with out going into your code and manually changing them. Like I said when I first started these tutorials, I want to try and make the game skinable so all you have to do to make a new game is edit the data files. Hopefully this will work out.
Role-Playing Game Tutorial 2
Tuesday, April 7, 2009
What is next...
Monday, April 6, 2009
First tutorial on Role-Playing game
Role-Playing Game Tutorial 1
Role-Playing Game Project
The NPC editor
I have been working hard on the editor and the tutorial on writing the editor. It is almost done and it should be posted very soon, maybe even tonight. In the editor I have elected to use XML Serialization instead of coding it by hand. I haven't yet added error checking when loading in XML files. I just want to get an editor working so you can start working on creating the different NPCs and monsters for the game. Which in itself can be fun.
It will be a while for the part for my notebook (up to three weeks) so I won't be able to do any XNA stuff. I will try to work on the design aspect until the part comes in. I know a lot of people just want to throw code at a problem but I am a firm believer in planning. I find that if you have a good plan for what you want to accomplish it is easier to work out what you need to do to accomplish your goals. I will also try and talk about some of the XNA specifcs that I am planning on using.
So tomorrow I will try and post some more about how the game will work in more detail. One thing that I am thinking about is having different difficulty levels. An easy mode, normal mode and hard mode. Easy mode characters will level up faster than normal mode characters but they will not get as many points to distribute between their attributes and skills. In hard mode it will take more experience to level up than normal characters but the character will get more points toward their skills and attributes.
Sunday, April 5, 2009
Delays, delays, delays...
Role-playing game specifications
First off it will be a single character game(I might expand it so that others may join your party.) It will be a skill based game instead of a class based game. In that way the player will be able to have more control over their character and they can choose how their character will develop. The character (and all other NPCs and creatures) will have six abilities. They will be Strength, Stamina, Agility, Speed, Intellect and Luck. Strength will help measure how much damage a character can do. Stamina will help determine how much damage a character can take. Agility will help in deteriming attack success and evasion. Speed will help a character strike first in combat. Intellect will determine the power of spells the character can cast. Luck will measure the ability of the character to have critical hits. I'm still working on the skills that a character will be able to learn.
The game will have a simple inventory system. Equipment will require certain levels of ability. For example a character with a low Strength will not be able to wear heavy armor and a character with low Intellect will not be able to learn sophisticated spells.
There will be three types of maps for the player to explore but they will all use the same tile engine to be displayed. The first is the adventure map where the player will be able to travel between towns and dungeons. Towns will have buildings the player can enter to buy equipment, rest, find quests, etc. Dungeons will be where the character will fight monsters. They will all behave relatively the same.
Combat will take place on a seperate screen. It will be a simple turn-based combat system. There will be an intiative roll that will be modified by Speed. The one with the highest intiative will go fisrt.
There will be a quest system where you will be able to find quests to perform. The quest system will be done using XML. It will use a content processor, importer and exporter so that the quests will be compiled into an XNB file.
I'm leaving right now to see about an adapter for my laptop. Hopefully they will have one and I will be able to start the tutorial on the tile engine. So check back soon and hopefully the tutorial will be up shortly.
Saturday, April 4, 2009
When it rains it pours...
Friday, April 3, 2009
The next tutorial
I find the documentation on how to check if a key has been pressed and released a little confusing. Here is a simple way to do it. You need to save the old state of the keyboard and compare it to the current state of the keyboard. I believe what they are checking is if the current state of the keyboard the key is down and the last state of the keyboard is up. I think that it works better if the current state of the keyboard is up and the last state of the keyboard is down.
So, create an XNA game. In the Game1.cs file add a variable at the top of the class to hold the old state of the keyboard and a variable to hold a color:
KeyboardState oldState;
Color bgColor = Color.White;
Now in the Update method add a call to a new method:
CheckKeyboard();
Now, write the CheckKeyboard method as follows:
private void CheckKeyboard()
{
KeyboardState currentState = Keyboard.GetState();
if (currentState.IsKeyUp(Keys.Space))
{
if (oldState.IsKeyDown(Keys.Space))
{
bgColor = new Color((byte)~bgColor.R,
(byte)~bgColor.G,
(byte)~bgColor.B);
}
}
oldState = currentState;
}
Now just replace the Color.CornflowerBlue in the Clear call to bgColor in the Draw method. When you run the program the screen should switch between black and white when you press the Space key and let it go.
Give it a try and see how it works. I am not posting the project for this simple tutorial.
Thursday, April 2, 2009
So, so sorry
This will be a 2D game with a scrolling map that you can have as many layers as you want and as many maps as you want. The quests will be fully customisable as well as the characters in the game. I will also be putting in utilities that will help you create quests, maps, items, etc. I want to try and do two or three posts each week to try and help you get started. Just remember, I am not an artist so the graphics will not be the best but there are many places on the Internet where you can find good quality graphics.
So look for the first post in a few days. It will be about creating a simple tile engine that will be at the heart of the game.