One thing Irrlicht is capable of is isometric game creation. I am absolutely sure some people will want to make such games, also, if you used a 2D tilemap in a 3D game, this would be useful.
The basic idea is as follows.
Here is our map (i will put it in a code box for the font):
Code: Select all
* = wall
= blank
0123456789
0**********
1* *
2* *
3* *
4* *
5* *
6* *
7* *
8* *
9**********
Code: Select all
* = wall
= blank
t = tank
d = destination
0123456789
0**********
1* *
2* d *
3* *
4* *
5* *
6* *
7* t *
8* *
9**********
the grid in number form looks like
Code: Select all
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 1 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
initialising, a boolean is set saying no moves have been done
1. The grid is scanned, if a number matches the current move number (whcich is incremented every move) the program then 'examines' this square.
2. It looks at the adjacent squares and checks their values
3. if the squares value is equal to 0 or greater than the next moves number, the program reassigns this grid value as the next moves number. A boolean is set saying a move has been done.
finalising. Once the array is fully scanned and changed the boolean is returned.
the result of doing this is as follows:
move 1:
Code: Select all
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 0 2 0 0 0 0 0 0 -1
-1 2 1 2 0 0 0 0 0 -1
-1 0 2 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Code: Select all
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 3 2 3 0 0 0 0 0 -1
-1 2 1 2 3 0 0 0 0 -1
-1 3 2 3 0 0 0 0 0 -1
-1 0 3 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
Code: Select all
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 3 2 3 4 0 0 0 0 -1
-1 2 1 2 3 4 0 0 0 -1
-1 3 2 3 4 0 0 0 0 -1
-1 4 3 4 0 0 0 0 0 -1
-1 0 4 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 0 0 0 0 0 0 0 0 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
the function would be written thus when implemented:
Code: Select all
int iMoves = 1;
while(ourFunction(iMoves))
iMoves++;
If the number in the grid at point 7, 7 were 0, the program would know the move were impossible.
If not the procedure does the following:
initialising. a boolean is set to false to indicate the target isn't reached.
1. Checks all 4 adjacenet squares and finds which has the lowest value and is greater or equal to 1
2. it moves to this square (sets its new coordanites to this square also for the next move!), if this square is equal to one, it returns true
note: if 2 squares are of equal value it can choose to use either square, you may wish to have an order like top first, then left, then bottom, then right. It doesn't realy matter.
this procedure is implemented in almost th exact same way:
Code: Select all
int iX = 7, iY = 7;
while(OurSecondFunction()){}//unfortunately there is no simple incrementing that can be done here so we input a blank statement in empty braces
If I feel sufficiently bored at a later date I may make a basic text screen demo for you and post the source (it would be written in DevCpp).
Well, I hopw the idea is clear and easy to understand and is of help to someone!
If I've made any mistakes please point them out immidietly!
This is intended as a starting point for someone who wishes to create their own Pathfinding for their game and make it as efficient as possible but doesn't know where to start. I know there are much better versions than this on the internet, but I recognise some people (like myself) want to do as much as they can by themselves, by giving out such basic information someone can excersize their own programming and logic to create their own much enhanced pathfinding.