Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / help in my code for animating my .x object using a function

Author
Message
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 24th May 2004 02:26
I used a function to load my levels and to append the animation data in my .x object. But the main problem is when i call the animation data (using keypresses), it won't work. where could i have gone wrong in my code? Thnk u to anyone who'll help me! Here's the code.

main:

do

rem u=horizontal shift, v=vertical shift
scroll object texture 100,0.0002,0.0: `sun
`---sun

` lensflare(2000,2001,qual)
`--------------------------------

`update the player
move_player(1,forward,backward,left,right,CurHp#)

super(1,turbo,CurHp#)

animate(1,tr1,tr2,tr3,tr4,tr5,anime,old_stage,stage)

gosub bar

gosub radar

watch(1)

control_player(2)

`update the camera
chase_cam(1)


for id=1 to 2
if score(id)=48
if id=1
gosub win
`spot=0
`spot2=0
exit:`function
else
`spot=0
`spot2=0
endif
endif
next id

collide()

`update the screen
sync
loop
return




function LoadWorld()
`make a temporary player object
make object cube 1,1
load object "media/chars/mel-idle.x",11:tr1=total object frames(11)
append object "media/chars/mel-run.x",11,tr1+1:tr2=total object frames(11)
append object "media/chars/mel-left.x",11,tr2+1:tr3=total object frames(11)
append object "media/chars/mel-right.x",11,tr3+1:tr4=total object frames(11)
append object "media/chars/mel-super.x",11,tr4+1:tr5=total object frames(11)
load image "media/melie3.jpg",11
texture object 11,11
scale object 11,5,5,5
glue object to limb 11,1,0
hide limb 1,0

function animate(id,tr1,tr2,tr3,tr4,tr5,anime,old_stage,stage)

if anime = 0

rem default idle state
stage = 0

if upkey() = 1 then stage = 1:anime = 1
if downkey() = 1 then stage = 1:anime = 1
if scancode() = 0 then stage = 0:anime = 0

else

if stage = 1 and object frame(11) = tr2 then anime = 0
endif

rem animation control, set speed, frame and loop
if stage <> old_stage

rem idle state
if stage = 0
set object speed 11,10
set object frame 11,0
loop object 11,0,tr1
endif

rem moving state
if stage = 1
set object speed 11,60
set object frame 11,tr1+1
loop object 11,tr1+1,tr2
endif

Ive'loaded the level using a separate gosub. And my PROBLEM is it won't animate. please help.

phukol
Lzdude69
21
Years of Service
User Offline
Joined: 21st May 2004
Location: Indiana
Posted: 24th May 2004 02:46
you forgot your endfunction

AlienSoftware
phukol
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location:
Posted: 25th May 2004 02:30
i just forot to paste it. I've used a different fomat in animating. I used the ninja animation routine found in one of DBC's example. thnx alien man

phukol

Login to post a reply

Server time is: 2025-05-24 06:08:05
Your offset time is: 2025-05-24 06:08:05