Archive for October, 2009

Banana Jump, Barrel Kick 1: Introduction.

Friday, October 16th, 2009

Banana Jump, Barrel Kick is a new small game I intend to create in C# and XNA.
I wish to write several blog posts that will follow my development of this game. I am learning a lot of new things here, and I don’t plan much up front. This means this might also fail, but if I won’t try, it has no chance of success either. I don’t know how often I will post about this project, and in what portions, but I hope that eventually there will be a complete game with source code people could learn from.
The game isn’t going to be too complicated. You can watch the header of PompiDev blog to see a sketch of this game. Or better yet, here is the image itself:

Banana Jump, Barrel Kick

Banana Jump, Barrel Kick

You will play a character running to the right that has to jump over bananas and kick rolling barrels. Thats it.
Take in account that I am developing on a windows vista, home premium 64 bit OS.

The first thing to do, is to subscribe to XNA creators club. Then you would need to go to Resources->Download, download and install Visual C# 2008 Express. After that return to Resources->Download, then download and install XNA Game Studio 3.1. I suggest to do all the 2D video tutorials under Education->Getting started, they are called “Beginner’s Guide to 2D Games”.
If it takes a while before I post again about this, you can try other tutorials and learn on your own, no need to wait for me. I will try to create code which “looks pretty” and hopefully has better design and practices than code of someone with little experience. I will also try to write about the lessons I will learn from coding this game.
Good luck to us all. :)

Motivation and efficiency while working on a single project?

Tuesday, October 13th, 2009

I have been developing Labyrinthica: The quest of lima for more than two years, in addition to working part time at a university. I was focused on a single project(my game) and didn’t spend time working on other projects. There were a lot of difficulties in motivation and efficiency. I enjoyed programming Laby a lot, but there were also times of very low motivation. There was also a period of two months I didn’t work on Laby at all because suddenly working on my game seemed like the most boring thing on earth.
Some developers might say “If you don’t like to work on your game, then maybe you are not ment to be a game developer”. I was like these developers at a certain point. I had tons of fun and motivation working on my game, thinking I was ment to be making games. But its a lot more complex than that.
I can’t entirely tell what will keep the flame(passion\motivation) burnning, but I can tell you what was my experience.

“Know your enemy” is not always a good thing. Labyrinthica is a single player game. I coded the enemy AI using finite state machine and steering behaviours. The problem with this approach? When I am play testing the game, I learn very quickly how every enemy behaves. I know what to expect, when they will chase me when they will go back. If a game is suppose to have 15 gameplay hours and you are testing it for 100 hours, you bet it won’t be as fun as playing some one’s else game as a new player. This is not entirely a bad thing, you don’t expect the developer to have the same experience as a player. However, there might be things to make your game more unexpected for yourself.
For instance, I have just been reading about genetic programming. Its a way to let the computer generate AI behaviour automatically that could perform as good as or even better than under human control.
You can use this to generate different AIs in a matter of seconds, and have a fresh and unfamiliar new AI to play against.

During the development I had all sort of ideas about how to implement new graphic shaders or all sort of game related solutions. Since I was so focused on my game, and those ideas were not relevant for Laby, I thought I shouldn’t invest time on trying to implement them. Implementing these things could mean less focus on your game. However, they could also boost your motivation in many ways.
What about learning? I did learn new game and non game related things here and there, but I didn’t think to invest too much time in learning new things. Because it would take too much time, and I need time to develop my game? right? The problem is that while developing a game is fun and rewarding, it is only a certain type of activity. Especially when you stop developing the “engine” and develop all the logic of the game, which could be the major part of the game. You need to vary your game related and non game related activities. Working on a game is one activity, and being creative is another activity. But learning is a very important activity. And by learning I mean, reading articles,  studying new technologies. When you work on your game, a big portion of it might be an activity that happens mostly with independent thought. In the most extreme case it means you don’t need anything external to your development environment and your brain. Learning would involve other people’s ideas, other people’s work. Something outside your own work. It could be very stimulating for the brain to learn something new that is related to you as a game developer. I hope I was clear enough about this. :)

What about efficiency? Efficiency is related to motivation. You don’t have to be 100% efficient, and its ok to have low efficiency. However, sometimes you have low efficiency and don’t realize it. I was working on something that made incremental build took a while(c++). Each time I was waiting for a build, I switched to my other computer and surfed the web. I found that I was spending time surfing the web more than the build took. Well, we are not robots, right? We are allowed to surf the web? I then decided to check how much time I spend on the web and how much time I work on my game. I decided I will work on my game in portions of one hour. I would work one hour on my game without any distractions, which also means watching the game build\compile. To my surprise, I discovered I worked 4  hours in a day and all those ”few moments ” spending on the web, really stacked. Less than what I thought I was working.
Now, I don’t suggest using strict methods to watch over your development time. Like using a program you click every time you start and end working on your game. This could be suitable for some people, but I know it won’t be suitable for me. I don’t want to be super efficient. However, making a reality check from time to time could help. Reducing compilation time might help as well. But most importantly, I think having other things to do except working on your game, which are brain stimulating, can help. And this bring me to my conclusion from my experience.
I think that working on two projects and having more game related and non game related things to do can increase your motivation and eventually productivity of working on your primary game.

Laby is almost complete. I am missing some sound and art assets to complete the game, but the game is mostly done.
I am planning to start working on other things. The things I plan to do are: Trying writing little games with C# and XNA, reading game related books and articles and implementing some shader ideas.
Working on multiple projects can easily make you lose focus on some or all your projects, moving from one project to another. I believe having one big primary project and one medium or small secondary project could be a good compromise, but this is something I am going to try and see for myself.
If you are a beginner, I would suggest working on very little projects. How small? Think of the smallest project you are willing to do, and make something a bit smaller than that. I would also suggest making one of the projects your primary project, but a primary project doesn’t mean it has to be big.

There is a lot more to say on this subject, and if programming is not entirely formal, then motivation and project handling is even more difficult to make sense of(for me). As always, I hope you take from my experience what suits you.

Embrace your inner beginner

Wednesday, October 7th, 2009

I have been looking at amazon on the book ”Advanced Game Programming: a gamedev.net collection“. A suggestion for another book called “Beginning Game Programming: a gamedev.net collection” was somewhere where I looked for the first book. Something almost drew me away from the book, because of the word “Beginning”, as if reading such a book would label me a “Beginner” which would seem to be a wrong label. Or is it? I looked inside the book, and I saw it covered some subjects I have no great knowledge about. Such as winsock2 and Lua. I decided to buy this book because it contained something useful for me.
Labeling books might help people decide if the book is suitable for them, but it might also do the opposite. Some people who just started programming might make use of something labeled for “experts”, and some experienced programmers might make use of material labeld as “beginners”. I think labels, in this respect, help people make choices when they don’t have any other thing to rely upon making this choice or they are too insecure.
I am not sure about the psychology behind this, or the consumerism perspective. I just suggest to try to think beyond the labels of books and labeling of yourself and don’t be afraid to sound like a beginner. This might help you be a better student or learner.

Copy paste and coding

Friday, October 2nd, 2009

Some people(my friend) think that if you can copy and paste some code it means it is a reusable code. That is wrong in two ways. First, reusable code means that the same code can be used in many different projects, it doesn’t say how many times you need it in one project. Secondly, as a rule of thumb, copy pasting in programming is a bad thing(sort of).
In this post I will not talk about reusable code, but rather how to avoid copy pasting. There is actually a very important mechanism for copy pasting in code. That is inheritance. Inheritance helps you copying the same code from one class into a new class, without actually having the same code written twice. Lets try to show a code example in C++.


class BaseSpriteDrawer {
public:
    void DrawCenter (int x, int y, Texture & t)
    {
     this->Draw (x-t.GetWidth()/2, y-t.GetHeight()/2, t);
    };
    virtual void Draw (int x, int y, Texture & t) = 0;
}


class SpriteDrawerA: public BaseSpriteDraw {            
public:
    void Draw (int x, int y, Texture & t);
};


class SpriteDrawerB: public BaseSpriteDraw {            
public:
    void Draw (int x, int y, Texture & t);
};

In this example you can see there are two different implementations for drawing sprites. Each one of those have different code for Draw. However, DrawCenter has the same code for both implementations so instead of writing the same code twice for each of the implementations, I have used inheritance. We have “copy pasted” the content of the class BaseSpriteDrawer or “copy pasted” DrawCenter.
The reason copy pasting is bad, is that you have the same code to maintain in two different places. If you discover a bug inside a function, you need to fix all the places you copy pasted that function. You just have more code to maintain, more copies of the same thing to maintain which translates into more work and more bugs.
There is also the additional bonus of saving you a lot of time. Sometimes you need the same code with small variations, and it would seem more work to figure out how to do this with inheritance, instead of just copy pasting and having two copies of the same code. However, in case you need a third copy of the code, with the inherited code it would be a lot easier to create the third “copy” of the code instead of copy pasting the same code for the second time.

If you are a beginner, I suggest you try to avoid copy pasting almost completely. It would be a good exercise or a good challenge to try doing something else each time you have the urge to copy paste some code. That being said, I myself don’t completely avoid copy pasting. While as a rule of thumb, its better to avoid copy pasting, sometimes its the fastest immediate solution. The thing is, not all of my code get the same treatment. Some code get better treatment than other code. If its code that is not so important and is not long, then I might copy paste it. I also might copy paste something, and when I see I get back to the same code to add something new, I would fix my bad practice of copy pasting and make a better, cleaner code.

There is a lot more to talk about this subject, and a lot more examples and techniques of how to avoid copy pasting. Copy pasting is actually implied from spartan programming, I have already mentioned spartan programming  and I hope to talk about it in future posts.

Links collection 1

Thursday, October 1st, 2009

I am getting close to complete Labyrinthica: The quest of lima and I am not doing much programming on the game. That means I have less programming related things to ponder about.
I thought I would share some unrelated links that might be useful.

  • How to sell your game - An article from amanda fitch about the final steps of selling your game. This includes setting up DRM and selling your game online.
  • Spartan Programming - This is a way to measure your code readability with certain metrics, to help you figure out how to program code that is easier to understand and easier to notice bugs in it. I will talk about it in more detail some day.
  • Objects Intersection - Seems like a very useful page if you need object intersection in your game. No need to reinvent the wheel.