Posted: 27th Nov 2003 23:31
Inspired by Interplay's M.A.X (1997), I'm going to try creating a TBS (turn-based strategy) game in DB Pro.
The first thing I've got working is the pathfinding system, which uses a variation of the A* algorithm (yes, another one ).
No proper graphics yet, so all you need to do is run the source code to see it in action.
There is one other file you need, which is a text file describing the map to be used. A sample one is available here:

http://darksun.united.net.kg/map.txt

Just bung it in the same dir as the exe.

How to use it:
The red squares are units. Click to select one, and click somewhere to send it off on a little expedition, avoiding all walls (white squares) in the way.

Controls:
Arrows: scroll screen
Ctrl/Shift: zoom (don't zoom out too far...)
Right click: add/delete wall

If you've got any comments/suggestions, please post them here.
This is only my 2nd DB project, so don't be too critical
Posted: 28th Nov 2003 1:19
Do have an exe or something for people without DB. I only have DBPro
Posted: 28th Nov 2003 7:30
This is DBP, notice the TYPEs and GLOBAL variables.
But it doesn't run, I get a "command out of place" error, line 391.
Posted: 28th Nov 2003 15:48
You can walk through corner:




I think that should be fixed.
Posted: 28th Nov 2003 16:44
I'll attack the cornering tonight and see what I can do. I suppose it's debatable whether units should be able to move between corners like this - depends on the game.
Posted: 28th Nov 2003 18:13
Yah, it doesn't even run for me. I worked forever trying to get it going, and I still can't get it.
Posted: 28th Nov 2003 19:08
Yah, it doesn't even run for me


What happens if you try and run it? Do you also get a 'line 391' error?
If so, I'm afraid I can't explain it. Why should the code compile any differently on my DBPro than yours? Weird.

If you're interested in seeing what it should look like, you can get an exe here:

http://darksun.united.net.kg/pathfinder.exe
Posted: 28th Nov 2003 23:42
I don't have the line 391 error, I have a 410 error. Then it starts saying that add array to stack has a problem. By the way, what patch are you using, that could be a clue.
Posted: 29th Nov 2003 1:51
As for cutting corners, you should check to see if the corner of the square being cut is walkable. If so, then go ahead and cut the corner, otherwise walk around it.

Tried the exe, runtime error 105 file does not exist at line 494. Did you compile it with the map.txt file or do I have have the two in the same directory?
Posted: 29th Nov 2003 3:18
As i said, it runs for me perfectly.
> patch 5 & newest editor.

Phaelax, make sure you run the EXE directly from where the map file exist.
If you run the EXE by using DBP, it could be that the EXE will be started from the TEMP directory, located where you have DBP installed, so it cant find the map.

HTH, Xanatus
Posted: 29th Nov 2003 11:52
Aye, that's what I thought. As for me, I'm still running patch 4.
Posted: 29th Nov 2003 14:09
OK, corners now work properly, it uses proper-ish (bitmap) graphics instead of squares, and runs a lot faster too.

http://darksun.united.net.kg/pfinder.zip

That zip includes an exe and all the media needed.
Posted: 29th Nov 2003 18:29
As for me, I'm still running patch 4.

Same here. I love it. Actually, I am running patch 4.1 and have I think about a year and a half's old DBPro, I don't know if that would make a difference.
Posted: 30th Nov 2003 5:42
Seems to work pretty fast. How many units do you think it could handle without slow down?
Posted: 30th Nov 2003 6:46
Did you get it to run Phaelax? Or did you download the EXE?
Posted: 30th Nov 2003 12:23
How many units do you think it could handle without slow down?


I get:
Default 2 units: 40FPS
Whole screen filled with units: 37FPS

It doesn't even try and draw any units which are off the screen, so it wouldn't drop any more frames if I added more off the screen.

At line 222, replace

+ Code Snippet
if mc=2
   if drV=1 then map(drvX,drvY,0)=0
   if drV=0 then map(drvX,drvY,0)=1
endif


with

+ Code Snippet
if mc=2
   if returnkey()
      spawn(drvX,drvY)
   else
      if drV=1 then map(drvX,drvY,0)=0
      if drV=0 then map(drvX,drvY,0)=1
   endif
   endif


then you can place units all over the map by holding return and right-clicing.
Posted: 30th Nov 2003 12:23
the exe. I'm using 4.1 like you. I dont see what the newer patch would change to make the structure differ like that.
Posted: 9th Dec 2003 5:55
This post has been quiet for quite some time
Posted: 9th Dec 2003 12:45
Long live A*, even though I can't figure out how to implement it.

@mcb, I understand the concept of A* in my head, and I have actually written some notes that can be translated to code fairly quickly, but I can't figure out one thing - how do I know what tile to check next: the tile with the lowest F score, or check them in the order that they were added to the open list? I could really use help on this one...
Posted: 12th Dec 2003 8:27
Actually maintaining and accessing the open and closed lists (especially the open list) is the hardest part of A*.

Most people approaching it for the first time either keep sorting the lists, or search the whole list to get the next item.

I used a different approach to mine - I used an arrangement known as a heap, which keeps the data arranged within an array so that the initial item is always the lowest cost, and maintenance is fast and cheap.

You can see example heap code in CodeBase : http://developer.thegamecreators.com/?m=codebase_view&i=604edc86c5cdb7db3d4d2681729356b0

You can also find my A* code in CodeBase, but I'll let you look for that yourself so that I don't get accused of hijacking this post