I made this in DBpro, but it doesnt work in DBpro yet... point object needs to work. I havent tested this in DBv1 (im too lazy to re-install it) so can anyone tell me if this does not work
sync on : sync rate 80 : make object cube 1,100 : make object cube 2,100 : set object rotation zyx 2
make object cube 3,100 : scale object 3,10,10,10 : set object rotation zyx 3 : make object box 4,100,100,500 : position object 4,-500,0,0
position camera 0,1000,0 : point camera 0,0,0 : hide object 3 : do : if upkey()=1 then inc z,10
if downkey()=1 then dec z,10
if rightkey()=1 then inc x,10
if leftkey()=1 then dec x,10
position object 1,x,y,z
shoot=line_of_sight(1,2,3)
if shoot=0 : color backdrop rgb(0,0,128) : endif
if shoot=1 : color backdrop rgb(128,0,0) : endif
if shoot=2 : color backdrop rgb(0,0,128) : point object 2,object position x(1),object position y(1),object position z(1) : move object 2,10 :endif
sync : loop
function line_of_sight(PlayerObj,EnemyObj,DummyObj)
pX = object position x(PlayerObj) : pY =object position y(PlayerObj) : pZ = object position z(PlayerObj) : eX = object position x(EnemyObj) : eY = object position y(EnemyObj)
eZ = object position z(EnemyObj) : distance = sqrt((pX-eX)^2 + (pY-eY)^2 + (pZ-eZ)^2) : set cursor 20,20 : print distance
scale object DummyObj,10,10,distance : position object DummyObj,(pX+eX)/2,(pY+eY)/2,(pZ+eZ)/2 : point object DummyObj,pX,pY,pZ
if object collision(3,4)=1 then shoot=0
if distance500 and object collision(3,4)=0 then shoot=2
endfunction shoot
If it works i will upload a more readable commented version.
Basically when you are within range of the enemy the screen should be red.
When you are out of range the screen will return blue and the enemy should follow you.
When you are behind a wall (collision detected so it should be quite slow in DBv1)the enemy will stop (i hope).
If it doesnt work I will re install V1 and see why it isnt working because I will want to use a modified version for my game.