forums

TNT Basic Forums > Programming Q&A
being followed
< Last Thread     Next Thread >
Author
Thread        Post A Reply

01-09-2004 17:39

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

im writing code for little people who follow you about, but i am having some problems getting them to stop next to the main character.
at the miniute they stop on/in/directly behind the main character
also, any suggestions as to how the people following might form a chain or a que.
ill post my code so you can see whats going on
here it is

procedure rescuables()

int i,n

for o=0to maxrescuables
if resex[o]=false
resex[o]=true
resx[o]=random(50,950)
resy[o]=random(100,700)
rescol[o]=false
resrad[o]=40
end if
next i

for n=0 to maxrescuables

if resex[n]=true
set sprite colour n+900,yellow
sprite n+900,resx[n],resy[n],38

if rescol[n]=true
resangle=calculate angle(resx,resy to shtrx,shtry)
resangle=resangle+270
'resrad2[n]=5'resrad[n]'+resangle[n]'shotangle[n] -resrad[n]+7

resx[n]=resrad2[n]*cos(resangle[n])+(shtrx-(xvel*10))
resy[n]=resrad2[n]*sin(resangle[n])+(shtry-(yvel*10))
end if

if sprite col(n+900,300)=300
rescol[n]=true
end if

end if

next n
end proc

any advice would be great and much appreciated

thanks
charlie

01-09-2004 22:16

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

One thing you could try is to have a little circle (or oval if you are doing an isometric view) sprite around your character's feet, and some more around the feet of the followers. What you would do before each frame is check to see if the sprite around the first person has overlapped the leader, and do not move them if this is the case, otherwise they should follow. Then, check the third to see if the second is overlapping, the fourth checks the third and so on down the line. If you don't want your man to be able to walk through his followers, things might get more difficult though. Oh well.

Have fun. I am using this method in my RPG.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.