Archive for February, 2009

Postpond with no bound time

Tuesday, February 10th, 2009

I have to admitted that currently I dont have enough time to
explain what I promised for Tank demo.

I am working on my current game project.
It would be nice if you guys wouldn’t mind for what situation I
have faced today.

I will come back and explain what I have promised next month.

So sorry for this sake.

Tank

Friday, February 6th, 2009

Quite long about 1 + 1/2 months that I have implemented almost all the things I knew about 3d graphics programming into this demo, Tank.

Features are listed here
- Terrain generating by procedural method.
- Model animation. (Model was created with the many different parts of mesh, and not contained the animation clip.)
- Camera movement
- Perlin noise (for cloud)
- The realistic calculation of the movement of the tank.
- Display vectors attached to the tank for its cannon, look at, and heading.
- Static shadow mapping with the point light.
- Improved the realistic of the environment.

That’s it, but this tank cannot blast the gun just yet, I dont’ have time for that now, but sooner or later I will implement it and usually make a simple multiplayer game for that.

Before we go down talk about my concept and implmentation itself, let’s me thanks someone out there that contributed great resource about how-to articles, and stuff that I learned from them, they are Rimers, Ziggyware, and GameDev. Without whom I cannot reach thus far.

And also due to this huge project, I will explain all of its implementation included section of code, one topic per week (as least). I just want to make sure that I cover all the detail, thus we wont go too fast.

The steps listed next is the topic that I will explain week by week, that it will begin by the next week on Monday, 9, Jan, 09

IMPLEMENTATION
The step to create this huge demo is these.
- Generate terrain.
- Create skydome to cover our terrain.
- Create the tank class to control all of its aspect including control, animation, etc.
- Create the effect drawing sheme, such as ‘Perlin Cloud’, ‘Shadow mapping on game world’.
- Put the tank on the terrain.
- Improve the movement of the tank by create the smooth and realistic movement of tank on the terrain.
- Tune our input manager (for tank movement, and camera control)
- Collect others detail.

So I simply say that we will go with this steps
Terrain -> SkyDome -> Model Animation -> Effect -> Integrate tank with terrain -> Input control -> Others miscs

Below is the sample screenshot from this demo,

Tank screenshot 1

Tank screenshot 1

Tank screenshot 2

Tank screenshot 2

Tank screenshot 3

Tank screenshot 3

I’m sure now you want to do like just that.
As I said, let’s begin next week on Monday, 9, Jan, on the topic of ‘Terrain Generating with procedural method’.

For the people who can go from their own, I have uploaded the projects file (its huge is mainly at the graphics and model content) here
http://www.savefile.com/files/1996427

Until next time, see you.

Space Shuttle control by 1MB of Ram?

Wednesday, February 4th, 2009

It’s true, as I read it from http://www.popsci.com/node/31716.

It consists of mainly operational functions, not included graphics other ram consuming.

I just wonder if the current technology that used in our PC’s software just takes this example as the step to focus on the memory consuming more and more, thus gives us more flexible use and reliable.

How can that come?

Ludumdare#13

Tuesday, February 3rd, 2009

Be ready for ludumdare#13, http://www.ludumdare.com.
It’s 48 Hour solo game developing.

Make sure you have an enough sleep. :)

Priority Queue

Tuesday, February 3rd, 2009

I know when you are doing your current project, you focus on its contents.
This let your less time to be spend on building the system or algorithm that need to support them.

By facing this by myself, when I do my game project’s AI system. It need the priority queue to support the sorted messages that will be send/receive across game entities in the world.

With less time to spend on building it from scratch, I look at CodeProject. It have much resource about programming.

So I grab it a try just to build from another one this time, you see the priority queue here Priority Queue, say thanks to BenDi.

Priority Queue use the binary tree to implement, so its complexity of O(log N) is enough to attract me.
Only one feature that missed from the original one is ‘allow no duplicated values to exist’.
So I try to implement it myself by extend from that one. (More easier though)

The idea is to perform checking for the existing value in the list first before add new value into the list.
It lists here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
            /// <summary>
            /// Push an object onto the PQ
            /// </summary>
            /// <param name="O">The new object</param>
            /// <returns>The index in the list where the object is _now_. This will change when objects are taken from or put onto the PQ.
            /// If the object is already existed in the list then return -99.</returns>
            public int Push(object O)
            {
                int p = InnerList.Count, p2;
                if (CheckValueInList(O) == -1)
                    InnerList.Add(O); // E[p] = O
                else
                    return -99;  //return, we dont do anything
                do
                {
                    if (p == 0)
                        break;
                    p2 = (p - 1) / 2;
                    if (OnCompare(p, p2) &lt; 0)
                    {
                        SwitchElements(p, p2);
                        p = p2;
                    }
                    else
                        break;
                } while (true);
                return p;
            }

You see that I call my CheckValueInList(O) before adding any new object, that method is implemented by using binary search, so the complexity is the same magnitude with binary tree thus O(log N).

This seems match you know!!

The code for CheckValueInList() is listed here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
            // Check the existance of the specified object in the list,
            // if it's exist then return the index of the existed object, otherwise return -1
            int CheckValueInList(Object O)
            {
                //if no element
                if (InnerList.Count == 0)
                    return -1;
 
                //binary search
                int low = 0;
                int high = InnerList.Count - 1;
                int mid;
                while (low &lt;= high)
                {
                    mid = low + (high - low) / 2;
                    if (Comparer.Compare(InnerList[mid], O) &lt; 0)
                        high = mid - 1;
                    else if (Comparer.Compare(InnerList[mid], O) &gt; 0)
                        low = mid + 1;
                    else
                        return mid; // found
                }
                return -1;
            }

The psedocode for binary search algorithm can be found from Wikipedia: Binary Search.
But note that BenDi use the IComparer, so I must strict to it and use this flexible feature that he build on.

Instead you can modify the OnCompare() method to match your type of data.
OnCompare() method is listed here.

1
2
3
4
5
            // Modify the code here to accommodate the type of data being compared.
            protected virtual int OnCompare(int i, int j)
            {
                return Comparer.Compare(InnerList[i], InnerList[j]);
            }

Thus from above you may cast it to your defined type and performing the comparision.
Like this.

1
2
3
4
5
6
7
8
9
10
11
12
            // Modify the code here to accommodate the type of data being compared.
            protected virtual int OnCompare(int i, int j)
            {
                if(InnerList[i] is MyType &amp;&amp; InnerList[j] is MyType)
               {
                      MyType obj1 = (MyType)InnerList[i];
                      MyType obj2 = (MyType)InnerList[j];
                      return Comparer.Compare(obj1, obj2);
                }
                //in this case only MyType type will be compared, otherwise return return
                return -99;
            }

This case I assume that you already overload operators for MyType, and that will be flexibly used in OnCompare() method.

Download project:pqtest