Instructions are in the demo. You basically swing the sword round the player by circlig the mouse about the player. I do plan to develop this, think it could lead to quite a quirky hack and slash system. Download the attached image to the same folder if you want an added special effect;
` sword system
sync on:sync rate 0:autocam off:set camera range 1,99999
color backdrop 0
` make world
make matrix 1,2000,2000,20,20
` make player
make object cube 1,60
` make sword
make object box 2,20,20,70
offset limb 2,0,0,0,100
` make swing
make object plain 3,270,270
xrotate object 3,270
ghost object on 3
set object transparency 3,2
` bomus special effect
if file exist("swing.jpg")
load image "swing.jpg",1
texture object 3,1
else
hide object 3
endif
` loop
do
` info
set cursor 0,0
print "** SWORD DEMO **"
print " "
print "- Move using WASD."
print "- Swing the sword by circling the"
print " mouse about the player object."
` controls
acc#=0.04
if keystate(17)=1 then vx#=vx#+newxvalue(0,ay#,acc#):vz#=vz#+newzvalue(0,ay#,acc#)
if keystate(31)=1 then vx#=vx#+newxvalue(0,ay#+180,acc#):vz#=vz#+newzvalue(0,ay#+180,acc#)
if keystate(32)=1 then vx#=vx#+newxvalue(0,ay#+90,acc#):vz#=vz#+newzvalue(0,ay#+90,acc#)
if keystate(30)=1 then vx#=vx#+newxvalue(0,ay#-90,acc#):vz#=vz#+newzvalue(0,ay#-90,acc#)
` speed
x#=x#+vx#:z#=z#+vz#:y#=y#+vy#
vx#=vx#/1.03:vz#=vz#/1.03
a#=atanfull(vx#,vz#)
position object 1,x#,y#,z#
`yrotate object 1,curveangle(a#,object angle y(1),15)
pitch object up 1,0.8
roll object right 1,0.8
turn object right 1,0.4
` sword
if mousey()>object screen y(1)
sv#=sv#-(mousemovex())
else
sv#=sv#+(mousemovex())
endif
if mousex()>object screen x(1)
sv#=sv#+(mousemovey())
else
sv#=sv#-(mousemovey())
endif
if sv#>300 then sv#=300
if sv#<-300 then sv#=-300
sa#=wrapvalue(sa#+sv#/80)
position object 2,x#,y#,z#
yrotate object 2,sa#
` swing
position object 3,x#,y#,z#
yrotate object 3,sa#
scale object 3,sv#,100,100
` sv
sv#=sv#/1.05
` mouse position
px#=object screen x(1):py#=object screen y(1)
mx#=mousex():my#=mousey()
` camera
point camera x#,10,z#
ay#=camera angle y()
` calculate camera position
cd#=-400
cx#=newxvalue(x#,ay#,cd#):cz#=newzvalue(z#,ay#,cd#):cy#=400
cx#=curvevalue(cx#,camera position x(),80)
cz#=curvevalue(cz#,camera position z(),80)
cy#=curvevalue(cy#,camera position y(),80)
` position
position camera cx#,cy#,cz#
` point
point camera x#,10,z#
` end loop
sync
loop