Hey Guys!
I have this problem with my Kirby animation.
I put up the simple code for it:
rem **************************************************
rem * KIRBY 64 RE-MAKE *
rem **************************************************
rem * author : The Comet *
rem * date : 29,2,2008 *
rem * end date : ? *
rem **************************************************
rem setup screen
sync on
sync rate 30
backdrop on
color backdrop 0
hide mouse
rem create everything
gosub load_images
gosub create_player
rem main loop
kscy=100
do
rem position camera
angle#=wrapvalue(angle#+mousemovex())
set camera to follow x#,y#,z#,angle#,50,0,2,0
point camera x#,y#,z#
rem position player
for t=100 to 104:position object t,0,5+sy#,0:next t
rem control player
if turn()=0
if leftkey()=1 or rightkey()=1
walk()
else
if grav#=0 and landed=1 then reset_player()
endif
else
if grav#=0 and landed=1 then reset_player()
endif
sy#=squash()
grav#=jump(sy#)
if grav#<>0 then landed=0
rem reset landing
if landed=0 and grav#=0 then landed=reset_feet()
rem refresh screen
sync
rem end of main loop
loop
rem ***************************************
rem * SUBROUTINES *
rem ***************************************
load_images:
rem load kirby
load image "textures/kirby/kirbyface.bmp",100
return
create_player:
rem make body
make object sphere 100,10
yrotate object 100,90
make mesh from object 1,100
delete object 100
make object 100,1,100
rem make arms
make object sphere 101,7
scale object 101,50,90,50
position object 101,0,0,4
xrotate object 101,340
make object sphere 102,7
scale object 102,50,90,50
position object 102,0,0,-4
xrotate object 102,20
rem make feet
make object sphere 103,7
scale object 103,90,50,50
position object 103,0,-5,2
make object sphere 104,7
scale object 104,90,50,50
position object 104,0,-5,-2
rem create limbs
for t=101 to 104
make mesh from object 1,t
delete object t
make object plain t,0,0
add limb t,1,1
if t<103
color limb t,1,rgb(253,199,215)
else
color limb t,1,rgb(255,0,0)
endif
next t
rem make core of kirby
make object plain 65000,0,0
return
rem ***************************************
rem * FUNCTIONS *
rem ***************************************
function walk()
rem get feet and head rotation
if frzv=1
frz=wrapvalue(frz+4)
else
frz=wrapvalue(frz-4)
endif
if frz>30 and frz<50 then frzv=0
if frz<330 and frz>310 then frzv=1
rem arm rotation
if frz=0 then ary#=0
if aryv=1
ary#=wrapvalue(ary#+2)
else
ary#=wrapvalue(ary#-2)
endif
if ary#>15 and ary#<30 then aryv=0
if ary#<345 and ary#>330 then aryv=1
rem rotate objects
if leftkey()=1
yrotate object 100,frz
rotate object 101,0,wrapvalue(0-ary#),wrapvalue(0-ary#)
rotate object 102,0,wrapvalue(0-ary#),ary#
zrotate object 103,frz
zrotate object 104,wrapvalue(0-frz)
endif
if rightkey()=1
yrotate object 100,wrapvalue(frz+180)
rotate object 101,0,wrapvalue(wrapvalue(0-ary#)+180),wrapvalue(0-ary#)
rotate object 102,0,wrapvalue(wrapvalue(0-ary#)+180),ary#
zrotate object 103,frz
zrotate object 104,wrapvalue(0-frz)
endif
endfunction
function turn()
rem get input
if rightkey()=1 and object angle y(65000)<>180 then right=1
if leftkey()=1 and object angle y(65000)>0 then left=1
rem rotate kirby
if right=1
turn=1
yrotate object 65000,wrapvalue(object angle y(65000)+20)
for t=100 to 104:yrotate object t,object angle y(65000):next t
endif
if left=1
turn=1
yrotate object 65000,wrapvalue(object angle y(65000)+20)
for t=100 to 104:yrotate object t,object angle y(65000):next t
endif
rem detect finish
if right=1
if object angle y(65000)>180 and object angle y(65000)<359
for t=100 to 104:yrotate object t,180:next t
yrotate object 65000,180
turn=0
right=0
endif
endif
if left=1
if object angle y(65000)>0 and object angle y(65000)<179
for t=100 to 104:yrotate object t,0:next t
yrotate object 65000,0
turn=0
left=0
endif
endif
endfunction turn
function reset_player()
rem get angles
cy=object angle y(65000)
hy=object angle y(100)
army=object angle y(101)
armz=object angle z(101)
footz=object angle z(103)
rem jump
if hy=0 and army=0 and armz=0 and footz=0 then goto endoffunction
rem if needed, yrotate kirby
if cy=180
for t=100 to 104:yrotate object t,0:next t
endif
rem reset head
if hy>0 and hy<40 then dec hy,4
if hy<360 and hy>320 then inc hy,4
rem reset arms
if army>0 and army<40 then dec army,2
if army<360 and army>320 then inc army,2
if armz>0 and armz<40 then dec armz,2
if armz<360 and armz>320 then inc armz,2
rem reset feet
if footz>0 and footz<40 then dec footz,4
if footz<360 and footz>320 then inc footz,4
rem rotate objects
yrotate object 100,hy
rotate object 101,0,army,armz
rotate object 102,0,army,wrapvalue(0-armz)
zrotate object 103,footz
zrotate object 104,wrapvalue(0-footz)
rem rotate back
endoffunction:
if cy=180
for t=100 to 104:yrotate object t,cy:next t
endif
endfunction
function squash()
rem get squash value
if downkey()=1
dec kscy,30
else
inc kscy,10
endif
if kscy<30 then kscy=30
if kscy>100 then kscy=100
rem scale kirby
for t=100 to 104
scale object t,100,kscy,100
sy#=(0.05*kscy)-5
position object t,object position x(t),object position y(t)+sy#,object position z(t)
next t
endfunction sy#
function jump(sy#)
rem detect upkey
if upkey()=1 and grav#=0 then grav#=2.0
rem move player up
grav#=grav#-0.1
y#=y#+grav#
if y#<0 then y#=0 : grav#=0.0
for t=100 to 104
position object t,object position x(t),y#+sy#,object position z(t)
next t
rem rotate feet
if grav#>1
zr#=wrapvalue(object angle z(103)+6)
zrotate object 103,zr#
zrotate object 104,zr#
endif
if grav#<1 and grav#<>0
zr#=wrapvalue(object angle z(103)-4)
if zr#<320 and zr#>280 then zr#=320
zrotate object 103,zr#
zrotate object 104,zr#
endif
rem rotate arms
xrotate object 101,wrapvalue(0-zr#)
xrotate object 102,zr#
endfunction grav#
function reset_feet()
rem rotate feet back to place
landed=0
rz#=object angle z(103)
if rz#>0 and rz#<180 then dec rz#,4
if rz#<360 and rz#>180 then inc rz#,4
rz#=wrapvalue(rz#)
zrotate object 103,rz#
zrotate object 104,rz#
rem reset arms
rx#=object angle x(101)
if rx#>0 and rx#<180 then dec rx#,6
if rx#<360 and rx#>180 then inc rx#,6
rx#=wrapvalue(rx#)
xrotate object 101,rx#
xrotate object 102,wrapvalue(0-rx#)
rem exit
if rz#=0 then landed=1 : rx#=0
endfunction landed
You will need to download the file attached and place the folder "textures" in with the DBC code.
This example generates the Kirby figure and adds animations to it. The left and right movements work fine. The squash movement works to. But when I jump, The legs twist back like normal, then twist forwards to land(like normal), while the arms move up(like normal), and down again(like normal), the arms stay down! I don`t know why the arms stay down, I have tried rotating them back to 0 degrees, but they just go back down!
Can someone please run through the code and find why that is so?
Thanks in advance, TheComet
Oooooops!!! I accidentally formated drive c.