Development Update (12/21/10)
The pathfinding demo was completed by me, with only the help of the Dark AI demo (no copy and paste lol). I am going to make some additions to it, add the unit object in it, and then implement into the game itself hopefully getting it all done today. I posted the simple pathfinding code (fully commented) below.
Rem Project: RTS Pathfinding by Zeus
Rem Created: Tuesday, December 21, 2010
Rem ***** Main Source File *****
REM Get the basic stuff done...
set display mode 800,600,32 `Set the screen resolution.
sync on : sync rate 0 `Set the sync rate.
backdrop on : color backdrop rgb(0,0,0) `Lets make the backdrop easier on the eyes.
autocam off `Get rid of this annoying little booger lol.
REM Initialize Dark AI...
AI Start
REM Lets set the global radius, every entity will be assumed this size...
AI Set Radius 2.5
REM Make the "world"...
make object box 100,100,1,100
position object 100,0,-0.5,0
color object 100,rgb(0,255,0)
REM Make the pathfinder...
make object cone 2,5
xrotate object 2,90
fix object pivot 2
position object 2,0,2.5,40
color object 2,rgb(rnd(255),rnd(255),rnd(255))
REM Add the pathfinder to the enemy team...
AI Add Friendly 2
AI Set Entity Speed 2,10.0
REM Make the mouse follower on the screen...
make object sphere 1,2 `Will be used when move=1 in the demo later...
color object 1,rgb(rnd(255),rnd(255),rnd(255))
REM Position the camera...
position camera 0,100,-30 : point camera 0,0,-5
do
REM Position the mouse follower to actually follow the mouse lol...
pick screen mousex(),mouseY(),1000
vx# = get pick vector x()
vy# = get pick vector y()
vz# = get pick vector z()
dy# = -camera position y()/vy#
vx# = vx#*dy# + camera position x()
vz# = vz#*dy# + camera position z()
position object 1,vx#,1,vz#
REM Let the magic happen...
if mouseclick()=1 then AI Entity Go To Position 2,object position x(1),object position z(1)
REM Dont let the pathfinder return to the starting point by resetting its idle position...
if ai get entity state$(2) = "Idle"
ai set entity idle position 2,ai get entity x(2),ai get entity z(2)
endif
REM Keep the AI updated...
AI Update
REM Sync.
sync
loop
-Zeus