Last night I decided to try and make a 2D object with limbs. Here is some cool stuff that I made along the way
Here's the final version of the first limb system I made.
Click on the joint you want to rotate and move the mouse horizontally.
`------------------------
` 2D Limbs
` By OBese87
`------------------------
hide mouse
white = rgb(255,255,255)
red = rgb(255,0,0)
green=rgb(0,255,0)
yellow = rgb(255,255,0)
`SIMPLE VERSION OF ONE JOINT
maxjoint=8
DIM Joint(maxjoint,4) : rem 0=Xpos, 1=Ypos, 2=Angle, 3=Limb_Length, 4=Parent
Joint(0,0)=200 : Joint(0,1)=200 : Joint(0,2)=90
For j = 1 to maxjoint
Joint(j,3)=10
m# = maxjoint
Joint(j,4)=rgb( (j/m#)*255,0,(1-(j/m#))*255)
Next j
sync on
`------------------------
` MAIN LOOP
`------------------------
DO
cls
print "FPS: "; screen FPS()
If mouseclick()=1
`Check joints
For j = 0 to maxjoint
if ABS(mousex()-Joint(j,0))<=5 and ABS(mousey()-Joint(j,1))<=5 and rotate=0
rotate = 1 : rj=j
endif
Next j
Endif
if rotate=1
print "Rotating Joint " ; rj; ": "; Joint(rj,2)
if mouseclick()=0 then rotate=0
m= wrapvalue( mousemovex() )
Joint(rj,2) = wrapvalue( Joint(rj,2)+m )
endif
`Draw Limbs
For lmb = 1 to maxjoint
a=0
For angle = lmb to 1 step -1
a = a+Joint(angle,2)
Next angle
Joint(lmb,0) = Joint(lmb-1,0)+sin(a)*Joint(lmb,3)
Joint(lmb,1) = Joint(lmb-1,1)+cos(a)*Joint(lmb,3)
ink Joint(lmb,4),0
~dline( Joint(lmb-1,0),Joint(lmb-1,1),Joint(lmb,0),Joint(lmb,1) )
Next lmb
For jnt = 0 to maxjoint
`draw joint
ink white,0
if rotate=1 and jnt=rj
circle Joint(jnt,0),Joint(jnt,1),1
else
Dot Joint(jnt,0),Joint(jnt,1)
endif
Next jnt
circle Joint(0,0),Joint(0,1),3
`Mouse
ink yellow,0
circle mousex(),mousey(),6
sync
LOOP
END
`------------------------
` FUNCTIONS
`------------------------
FUNCTION ~dline(l,t,r,b) : `sp is for dotted lines!
sp=1
w = r-l : h = b-t
if w >= 0 then xstep = 1*sp else xstep = -1*sp
if h >= 0 then ystep = 1*sp else ystep = -1*sp
w# = ABS(w) : h# = ABS(h)
if w#=0 then w#=0.1
if h#=0 then h#=0.1
xfact# = w#/h#
yfact# = h#/w#
x = 0 : y = 0
repeat
`don't overshoot
if abs(x+xstep) > abs(w) then xstep = 0
if abs(y+ystep) > abs(h) then ystep = 0
dot x+l,y+t
if yfact# > xfact#
inc y,ystep
if ABS(x) < ABS(y*xfact#) then inc x,xstep
else
inc x,xstep
if ABS(y) < ABS(x*yfact#) then inc y,ystep
endif
until xstep = 0 and ystep = 0
ENDFUNCTION
After making that and finding that making a gradient is pretty easy, I played around with the idea. Still can't get a diagonal gradient across the whole screen
set display mode 640,480,32
hide mouse
sync on
sx#=640 : sy#=480
For y = 0 to sy# step 1
ink rgb( (y/sy#)*255,0,(1-(y/sy#))*255),0
line 0,y,639,y
Next y
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
line (xy/sy#)*sx#,(xy/sy#)*sy#,(1-(xy/sy#))*sy#,1-(xy/sy#)
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
x1=(xy/sy#)*sx# : y1=(xy/sy#)*sy#
x2=(1-(xy/sy#))*sy# : y2=(1-(xy/sy#))*sy#
line x1,y1,x2,y2
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
x1=(xy/sy#)*xy : y1=(xy/sy#)*sy#
x2=(1-(xy/sy#))*xy : y2=(1-(xy/sy#))*sy#
line x1,y1,x2,y2
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
x1=(xy/sx#)*sx# : y1=(xy/sy#)*sy#
x2=(1-(xy/sx#))*sx# : y2=(1-(xy/sy#))*sy#
line x1,y1,x2,y2
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
line (xy/sy#)*sx#,(1-(xy/sy#))*sx#,0,xy
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
line (xy/sy#)*sx#,(1-(xy/sy#))*sy#,(1-(xy/sy#))*sy#,(1-(xy/sy#))*sx#
Next xy
sync
wait key
cls
For xy = 0 to sy# step 1
ink rgb( (xy/sy#)*255,0,(1-(xy/sy#))*255),0
line (xy/sy#)*sx#,0,0,(1-(xy/sy#))*sy#
Next xy
sync
wait key
After messing around with that I messed around with my 2D limbs

I call this the Spiral Whip! Can't seem to get it to curl into the centre
`------------------------
` 2D SPIRAL WHIP
`------------------------
hide mouse
white = rgb(255,255,255)
red = rgb(255,0,0)
green=rgb(0,255,0)
yellow = rgb(255,255,0)
`SIMPLE VERSION OF ONE JOINT
maxjoint=100
DIM Joint(maxjoint,4) : rem 0=Xpos/offset, 1=Ypos/offset, 2=Angle, 3=Limb_Length, 4=Limb Colour
Joint(0,0)=320 : Joint(0,1)=240 : Joint(0,2)=90
For j = 1 to maxjoint
Joint(j,3)=3
m# = maxjoint
Joint(j,4)=rgb( (j/m#)*255,0,(1-(j/m#))*255)
Next j
sync on
`------------------------
` MAIN LOOP
`------------------------
DO
cls
print "FPS: "; screen FPS()
inc deg,1
`Draw Limbs
For lmb = 1 to maxjoint
a=0
For angle = lmb-1 to 0 step -1
` a = a+Joint(angle,2)
a = a+Joint(angle,2) + sin(deg)*60
Next angle
Joint(lmb,0) = Joint(lmb-1,0)+sin(a)*Joint(lmb,3)
Joint(lmb,1) = Joint(lmb-1,1)+cos(a)*Joint(lmb,3)
ink Joint(lmb,4),0
~dline( Joint(lmb-1,0),Joint(lmb-1,1),Joint(lmb,0),Joint(lmb,1) )
Next lmb
ink white,0
circle Joint(0,0),Joint(0,1),3
sync
LOOP
END
`------------------------
` FUNCTIONS
`------------------------
FUNCTION ~dline(l,t,r,b) : `sp is for dotted lines!
sp=1
w = r-l : h = b-t
if w >= 0 then xstep = 1*sp else xstep = -1*sp
if h >= 0 then ystep = 1*sp else ystep = -1*sp
w# = ABS(w) : h# = ABS(h)
if w#=0 then w#=0.1
if h#=0 then h#=0.1
xfact# = w#/h#
yfact# = h#/w#
x = 0 : y = 0
repeat
`don't overshoot
if abs(x+xstep) > abs(w) then xstep = 0
if abs(y+ystep) > abs(h) then ystep = 0
dot x+l,y+t
if yfact# > xfact#
inc y,ystep
if ABS(x) < ABS(y*xfact#) then inc x,xstep
else
inc x,xstep
if ABS(y) < ABS(x*yfact#) then inc y,ystep
endif
until xstep = 0 and ystep = 0
ENDFUNCTION

Finally, here is my stick man skeleton: I haven't added any joint angle limits yet so he's "flexible"

Click on the joint you want to rotate and move the mouse horizontally.
`------------------------
` STICKMAN SKELETON
` By OBese87
`------------------------
hide mouse
white = rgb(255,255,255)
red = rgb(255,0,0)
green=rgb(0,255,0)
yellow = rgb(255,255,0)
`SIMPLE VERSION OF ONE JOINT
maxjoint=14
DIM Joint(maxjoint,4) : rem 0=Xpos, 1=Ypos, 2=Angle, 3=Limb_Length, 4=Parent
`Waist (Root)
Joint(0,0)=320 : Joint(0,1)=240
`Right Knee
Joint(1,2)=30 : Joint(1,3)=20 : Joint(1,4)=0
`Right Foot
Joint(2,2)=-30 : Joint(2,3)=20 : Joint(2,4)=1
`Left Knee
Joint(3,2)=-30 : Joint(3,3)=20 : Joint(3,4)=0
`Left Foot
Joint(4,2)=30 : Joint(4,3)=20 : Joint(4,4)=3
`Spine 1 (Lumbar)
Joint(5,2)=180 : Joint(5,3)=10 : Joint(5,4)=0
`Spine 2(Thoracic)
Joint(6,2)=0 : Joint(6,3)=10 : Joint(6,4)=5
`Spine 3 (C)
Joint(7,2)=0 : Joint(7,3)=10 : Joint(7,4)=6
`Right Shoulder
Joint(8,2)=92 : Joint(8,3)=10 : Joint(8,4)=7
`Right Elbow
Joint(9,2)=0 : Joint(9,3)=10 : Joint(9,4)=8
`Right Hand
Joint(10,2)=0 : Joint(10,3)=10 : Joint(10,4)=9
`Left Shoulder
Joint(11,2)=-90 : Joint(11,3)=10 : Joint(11,4)=7
`Left Elbow
Joint(12,2)=0 : Joint(12,3)=10 : Joint(12,4)=11
`Left Hand
Joint(13,2)=0 : Joint(13,3)=10 : Joint(13,4)=12
`Head
Joint(14,2)=0 : Joint(14,3)=10 : Joint(14,4)=7
sync on
`------------------------
` MAIN LOOP
`------------------------
DO
cls
print "FPS: "; screen FPS()
If mouseclick()=1
`Check joints
For j = 1 to maxjoint
if ABS(mousex()-Joint(j,0))<=5 and ABS(mousey()-Joint(j,1))<=5 and rotate=0
rotate = 1 : rj=j
endif
Next j
Endif
if rotate=1
print "Rotating Joint " ; rj; ": "; Joint(rj,2)
if mouseclick()=0 then rotate=0
m= wrapvalue( mousemovex() )
Joint(rj,2) = wrapvalue( Joint(rj,2)+m )
endif
`Draw Limbs
For lmb = 1 to maxjoint
a=0
par=lmb
While par<>0
a=a+Joint(par,2)
par=Joint(par,4)
Endwhile
par=Joint(lmb,4)
Joint(lmb,0) = Joint(par,0)+sin(a)*Joint(lmb,3)
Joint(lmb,1) = Joint(par,1)+cos(a)*Joint(lmb,3)
ink red,0
~dline( Joint(par,0),Joint(par,1),Joint(lmb,0),Joint(lmb,1) )
` line Joint(par,0),Joint(par,1),Joint(lmb,0),Joint(lmb,1)
Next lmb
circle Joint(14,0),Joint(14,1),4 : `head
For jnt = 0 to maxjoint
`draw joint
ink white,0
if rotate=1 and jnt=rj
circle Joint(jnt,0),Joint(jnt,1),1
else
Dot Joint(jnt,0),Joint(jnt,1)
endif
Next jnt
circle Joint(0,0),Joint(0,1),3
`Mouse
ink yellow,0
circle mousex(),mousey(),6
sync
LOOP
END
`------------------------
` FUNCTIONS
`------------------------
FUNCTION ~dline(l,t,r,b) : `sp is for dotted lines!
sp=1
w = r-l : h = b-t
if w >= 0 then xstep = 1*sp else xstep = -1*sp
if h >= 0 then ystep = 1*sp else ystep = -1*sp
w# = ABS(w) : h# = ABS(h)
if w#=0 then w#=0.1
if h#=0 then h#=0.1
xfact# = w#/h#
yfact# = h#/w#
x = 0 : y = 0
repeat
`don't overshoot
if abs(x+xstep) > abs(w) then xstep = 0
if abs(y+ystep) > abs(h) then ystep = 0
dot x+l,y+t
if yfact# > xfact#
inc y,ystep
if ABS(x) < ABS(y*xfact#) then inc x,xstep
else
inc x,xstep
if ABS(y) < ABS(x*yfact#) then inc y,ystep
endif
until xstep = 0 and ystep = 0
ENDFUNCTION
Work In Progress:-

3-Axis rotation of limbs

Animation memory and playback

Editor to create and animate custom 2D models
Your signature has been erased by a mod because it was rubbish.