cool, ah anime i got a problem since i have to do the battle engine over, i got a question. Why is my animation jerky?
sync on:sync rate 30
color backdrop rgb(50,50,255)
ink rgb(0,0,0),rgb(0,0,0)
randomize timer()
dim key(256)
type enem
health as integer
startx as integer
startz as integer
endx as integer
endz as integer
move as integer
scale as integer
endtype
dim enemy(100) as enem
make object box 9,10000,5,10000
move object down 9,5
color object 9,rgb(100,255,100)
for a=10 to 100
make object sphere a,3,6,6
position object a,rnd(1000),0,rnd(1000)
color object a,rgb(255,0,0)
enemy(a).health=100
enemy(a).startx=object position x(a)
enemy(a).startz=object position z(a)
enemy(a).endx=object position x(a)+rnd(60)
enemy(a).endz=object position z(a)+rnd(60)
enemy(a).scale=100
next a
load object "dwarf1.x",1
scale object 1,50,50,50
set object ambient 1, 0
set object speed 1, 30
loop object 1, 3, 14
playerhealth=100
make object box 2,.2,.2,4
color object 2,rgb(0,0,0)
hide object 2
offset limb 2,0,0,0,2
do
if upkey()=1 then move object 1,1
if downkey()=1 then move object 1,-1
if leftkey()=1 then yrotate object 1,object angle y(1)-5
if rightkey()=1 then yrotate object 1,object angle y(1)+5
if keyready(57)=1 and attack=0
rotate object 2,object angle x(1),object angle y(1)-70,object angle z(1)
attack=16
show object 2
endif
if attack>0
attack=attack-1
position object 2,object position x(1),0,object position z(1)
yrotate object 2,object angle y(2)+10
for a=10 to 100
if object exist(a)=1
if object collision(2,a)=1
enemy(a).health=enemy(a).health-30
move object a,-20
enemy(a).scale=enemy(a).scale-20
scale object a,enemy(a).scale,enemy(a).scale,enemy(a).scale
endif
if enemy(a).health<10 then delete object a
endif
next a
endif
if attack=1 then hide object 2
for a=10 to 100
if object exist(a)=1
if distance(1,a)>50
patrol(a)
else
point object a,object position x(1),0,object position z(1)
move object a,.5
if object collision(a,1)=1
playerhealth=playerhealth-5
move object a,-15
endif
endif
endif
next a
position camera (object position x(1)-sin(object angle y(1))*5),object position y(1)+2,(object position z(1)-cos(object angle y(1))*5)
point camera object position x(1),object position y(1),object position z(1)
text 1,1,str$(playerhealth)
sync
loop
function patrol(object)
if threeD_distance(object position x(object),enemy(object).endx,0,0,object position z(object),enemy(object).endz)<2 then enemy(object).move=1
if threeD_distance(object position x(object),enemy(object).startx,0,0,object position z(object),enemy(object).startz)<2 then enemy(object).move=0
if enemy(object).move=0
point object object,enemy(object).endx,0,enemy(object).endz
move object object,1
endif
if enemy(object).move=1
point object object,enemy(object).startx,0,enemy(object).startz
move object object,1
endif
endfunction
function distance(obj1,obj2)
dist=sqrt(((object position x(obj1)-object position x(obj2))*(object position x(obj1)-object position x(obj2)))+((object position z(obj1)-object position z(obj2))*(object position z(obj1)-object position z(obj2))))
endfunction dist
FUNCTION threeD_distance(x1# AS float, x2# AS float, y1# AS float, y2# AS float, z1# AS float, z2# AS float)
temp = 1
null = make vector3(temp)
set vector3 temp, x1# - x2#, y1# - y2#, z1# - z2#
length_vector = abs(length vector3(temp))
null = delete vector3(temp)
ENDFUNCTION length_vector
function keyready(keyz)
vl=0
if keystate(keyz)=1 and key(keyz) = 0
key(keyz) = 1
vl=1
endif
if keystate(keyz)=0
key(keyz) = 0
vl = 0
endif
endfunction vl