Here's some cool functions I made for use in Los Mineros. They have to do with making ropes:
function DrawRopes(RopeStart)
for c=1 to Array Count(RopeSegments(0))
SpriteNo=c+RopeStart-1
if sprite exist(SpriteNo)=0
sprite SpriteNo,0,0,RopeImageNumber
offset sprite SpriteNo,sprite width(SpriteNo)/2,sprite height(SpriteNo)/2
endif
sprite SpriteNo,b2GetBodyX(RopeSegments(c)),b2GetBodyY(RopeSegments(c)),RopeImageNumber
rotate sprite SpriteNo,wrapvalue(b2GetBodyAngle(RopeSegments(c))+90)
next c
endfunction
function MakeRope(linkers)
array insert at bottom RopeSegments(0)
RopeNumber=array count(RopeSegments(0))
RopeSegments(RopeNumber)=b2CreateBoxBody(FirstLevel,image height(3),image width(3),0.1,0.1,5)
b2PositionBody RopeSegments(RopeNumber),50,50
oldbody=RopeSegments(RopeNumber)
for i = 1 to linkers-1
array insert at bottom RopeSegments(0)
RopeNumber=array count(RopeSegments(0))
RopeSegments(RopeNumber)=b2CreateBoxBody(FirstLevel,image height(3),image width(3),0.1,0.1,5)
b2PositionBody RopeSegments(RopeNumber),(i*image height(3))+50,50
tempjnt=b2CreateRevoluteJoint(FirstLevel,oldbody,RopeSegments(RopeNumber),b2GetBodyX(RopeSegments(RopeNumber))-image height(3)/2,50)
oldbody=RopeSegments(RopeNumber)
next i
endfunction
function InitRopes(ImgNumber)
global RopeImageNumber
RopeImageNumber=ImgNumber
create bitmap 1,4,12
set current bitmap 1
ink rgb(128,64,0),0
for c=1 to 4
line c,1,c,12
next c
ink rgb(1,1,1),0
for c=1 to 4
dot c,c
dot c,c+1
dot c,c+6
dot c,c+7
next c
get image RopeImageNumber,1,1,4,12
delete bitmap 1
To initiate the ropes, call RopeInit(ImgNumber). ImgNumber is the number in which it will store the rope image, so it needs to be a free image number.
To make a rope, call MakeRope(Links). Links is the number of links the rope will have, experiment to get a good number.
Then, calling DrawRopes(RopeStart) every loop will update the sprites that represent the rope bodies. RopeStart should be the highest sprite number in your program, because the sprites will be numbered from that number up. (For example, if you had one 25-link rope and you put a RopeStart of 100, the first link would be sprite 100, the second sprite 101, the third sprite 102, etc.
I'll probably come up with more stuff to do with your ropes as I work on Los Mineros.