waypoint help

Blitz3D Forums/Blitz3D Programming/waypoint help

To create waypoints you would maybe best write a waypoint recorder. So YOU walk trough the level, in first person perspective, and your way is recorded and then used for the patrols.

you can use timebased recording or distancebased recording, it doesn't matter that much.

Try something like:
dim wp#(2,100000)
while not keydown(1)
 ; here would be player controls
 if millisecs()>tt
  tt=millisecs()+200 ; record a point every 200ms
  wp(0,count)=entityx(player)
  wp(1,count)=entityy(player)
  wp(2,count)=entityz(player)
  count=count+1
 endif
 renderworld()
 flip
wend

wr=writefile("waypoint.dta")
for i=0 to count-1
writefloat wr,wp(0,i)
writefloat wr,wp(1,i)
writefloat wr,wp(2,i)
next
closefile wr


and to load the waypoints you would hen have to:

;first check how many waypoint must be reserved
;(maybe this could be done more clever, eg. by filesize/12)
count=0
re=readfile("waypoint.dta")
while eof(re)=0
 dummy#=readfloat(re)
 dummy#=readfloat(re)
 dummy#=readfloat(re)
 count=count+1
wend
closefile re

dim wp#(2,count-1)

re=readfile("waypoint.dta")
for i=0 to count-1
 wp(0,i)=readfloat(re)
 wp(1,i)=readfloat(re)
 wp(2,i)=readfloat(re)
next
closefile re