Posted: 11th Jun 2007 20:22
Hi guys,

+ Code Snippet
' #################MAIN LOOP######################

DO

`ELAPSED TIME
   `************************************************
   `Get the amount of elspsed time since the last time check
   elapsedTime = timer() - time
   `Reset the time check
   time = timer()

   `UPDATE THE OAC
   `************************************************
   `SYNTAX: EnAn_oacUpdate oacID, elapsedTime
   EnAn_oacUpdate oacID, elapsedTime

      `If user presses the up key, and character is not already Walking, then set the character to walk
 if  ground = 1 and keystate(17) = 1 and MoveMode <> Move_WalkUp  and keystate(31) = 0 and keystate(32) = 0 and keystate(30) = 0 and spacekey()=0
         EnAn_AnimSetPlaySpeed WalkAnim, framerate
         EnAn_oacAnimTransition oacID, spine, WalkAnim, 0, 0, -1, transTime, DoLoop, IncChild
         MoveMode = Move_Walkup
   endif


 `WALKdown:
      `If user presses the down key, and character is not already Walking, then set the character to walk
 if   ground = 1 and keystate(31) = 1 and MoveMode <> Move_WalkDown  and  keystate(17) = 0  and keystate(32) = 0 and keystate(30) = 0 and spacekey()=0
        EnAn_AnimSetPlaySpeed WalkAnim, revframerate
         EnAn_oacAnimTransition oacID, spine, WalkAnim, 0, 0, -1, transTime, DoLoop, IncChild
         MoveMode = Move_WalkDown
   endif

 `WALKleft:
      `If user presses the left key, and character is not already Strafing, then set the character to walk
 if   ground = 1 and keystate(30) = 1 and MoveMode <> Move_StrafeLeft   and  keystate(17) = 0 and keystate(31) = 0 and keystate(32) = 0 and spacekey()=0
         EnAn_AnimSetPlaySpeed StrafeAnim, framerate
         EnAn_oacAnimTransition oacID, spine, StrafeAnim, 0, 0, -1, transTime, DoLoop, IncChild
       MoveMode = Move_StrafeLeft
   endif


`WALKright:
      `If user presses the right key, and character is not already Strafing, then set the character to walk
if ground = 1 and keystate(32) = 1 and MoveMode <> Move_StrafeRight  and  keystate(17) = 0 and keystate(31) = 0  and keystate(30) = 0 and spacekey()=0
         EnAn_AnimSetPlaySpeed StrafeAnim, revframerate
         EnAn_oacAnimTransition oacID, spine, StrafeAnim, 0, 0, -1, transTime, DoLoop, IncChild
         MoveMode = Move_StrafeRight
   endif



`STOPPING:
`If no movement keys are being pressed and character is not already stopped, then stop
if MoveMode <> Move_Stand and ground = 1 and  keystate(17) = 0 and keystate(31) = 0 and keystate(32) = 0 and keystate(30) = 0  and spacekey()=0
       EnAn_oacAnimTransition oacID, spine, StandAnim, 0, 0, -1, 400, DoLoop, IncChild
       MoveMode = Move_Stand
endif

if MoveMode <> Move_Stand and ground = 1 and  keystate(17) = 1 and keystate(31) = 1 and keystate(32) = 0 and keystate(30) = 0 and spacekey()=0
       EnAn_oacAnimTransition oacID, spine, StandAnim, 0, 0, -1, 400, DoLoop, IncChild
       MoveMode = Move_Stand
endif

if MoveMode <> Move_Stand and ground = 1 and  keystate(17) = 0 and keystate(31) = 0 and keystate(32) = 1 and keystate(30) = 1  and spacekey()=0
       EnAn_oacAnimTransition oacID, spine, StandAnim, 0, 0, -1, 400, DoLoop, IncChild
       MoveMode = Move_Stand
endif


`JUMPING/FALLING and LANDANIM:
`If no movement keys are being pressed and character is not already stopped, then stop

if ground = 0
EnAn_AnimSetPlaySpeed JumpAnim, 30 :EnAn_oacAnimTransition oacID, spine, JumpAnim, 0, 0, -1, 60, NoLoop, IncChild
endif


if ground = 1 and jumptimer > 0
               EnAn_AnimSetPlaySpeed LandAnim, 100
               EnAn_oacAnimTransition oacID, spine, LandAnim, 0, 0, -1, 60, NoLoop, IncChild
               MoveMode = Move_Jump
               endif



handleExtraSpheres(numSpheres)
MovePlayer()
triggerzones()


sync
loop



Here is my main loop. I really want my werewolf to start walking again after he has gone through his jump and land animations, but he just stops after his land loop , which is this bit:

+ Code Snippet
`JUMPING/FALLING and LANDANIM:
`If no movement keys are being pressed and character is not already stopped, then stop

if ground = 0
EnAn_AnimSetPlaySpeed JumpAnim, 30 :EnAn_oacAnimTransition oacID, spine, JumpAnim, 0, 0, -1, 60, NoLoop, IncChild
endif


if ground = 1 and jumptimer > 0
               EnAn_AnimSetPlaySpeed LandAnim, 100
               EnAn_oacAnimTransition oacID, spine, LandAnim, 0, 0, -1, 60, NoLoop, IncChild
               MoveMode = Move_Jump
               endif



handleExtraSpheres(numSpheres)
MovePlayer()
triggerzones()


sync
loop



Can anybody withexperience of enhanced animations help?

Thanks

Danny

p.s. In my next post I will attach the whole folder with everything in, as someone might find it more useful to load it all up and see the problem that way !

Thanks again for your time...

Dan
Posted: 11th Jun 2007 20:37
Danny,

All you need to do is check to see if your object's current animation is the "land" animation. If that is true and it's current frame is the last frame of the "land" animation, then transition to your walk animation again.

If that doesn't explain things well enough, let me know. I'll write a little snippet for you.

-Ron
Posted: 11th Jun 2007 21:23
Hi Wolf, please could you have a look at my code. I tried to do something similar to your suggestion but couldn't get it working.

I obviously want him to start walking forward or backwards or sideways again if the user is still pressing the corresponding direction key, when the werewolf lands.

Thanks so much

I couldnt get my .zip file to upload for some reason so you can download it here if you like:

http://www.uniquegraphics.co.uk/WOLF.zip
Posted: 11th Jun 2007 22:18
I will try to look at this later today or tomorrow.
Posted: 12th Jun 2007 6:16
OK... I had a look at your code and tried out your example.

Try replacing the jump/land portion of your code with this:

+ Code Snippet
if ground = 0
walk = 0
EnAn_AnimSetPlaySpeed JumpAnim, 30 :EnAn_oacAnimTransition oacID, spine, JumpAnim, 0, 0, -1, 60, NoLoop, IncChild
endif


if ground = 1 and EnAn_oacGetLimbPlayAnimID( oacID, spine ) = JumpAnim and jumptimer > 0 and jumptimer < 39
               EnAn_AnimSetPlaySpeed LandAnim, 100
               EnAn_oacAnimTransition oacID, spine, LandAnim, 0, 0, -1, 60, NoLoop, IncChild
               MoveMode = Move_Landed
endif
if ground = 1 and EnAn_oacGetLimbPlayAnimID( oacID, spine ) = LandAnim and EnAn_oacGetCurrentFrame( oacID, spine ) = EnAn_AnimGetTotalFrames( LandAnim )
               `EnAn_AnimSetPlaySpeed LandAnim, 100
               EnAn_oacAnimTransition oacID, spine, StandAnim, 0, 0, -1, 60, NoLoop, IncChild
               MoveMode = Move_Stand
endif


I hope this helps! Good luck with your project
Posted: 12th Jun 2007 6:37
This may be the same thing that WOLF posted, but darkbasic's animation commands typically don't work in exact integers, meaning that the object's frame could be like 59.38298470192837401928 when it's done with an animation. So rather than "if object frame(1) =60" you might want to use "if object frame(1) > 59" This is just a general example, I didn't actually read through your code, but I hope it might have helped.
Posted: 12th Jun 2007 7:09
Brain111,

He is talking about the use of Enhanced Animations, which is an official addon for DBpro (written by me )
Check it out here:
http://darkbasicpro.thegamecreators.com/?f=enhanced_animations
Posted: 12th Jun 2007 9:09
@Brain111 -
Worse than that, if you're using timer based animation and the framerate is low or suddenly lags, you can totally skip a particular frame. That can make footsteps irregular, in addition to making other frame dependent events unreliable. There are mathematical ways to improve it, but they are messy and involve too many comparisons.

Sadly, I can't use Wolf's awesome plugin because I can't use the latest version of DBP for Geisha House. There are too many issues that mess up the project. I wrote my own animation plugin for it instead. Every 1/4 of the way through the animation, the plugin returns a flag. It provides clean looking code and is faster than running all of the comparisons in DBP. With this method I can sync footsteps and spellcasting sounds to animations.

I recommend writing an animation controller function that does this. That's what I did first.
Posted: 12th Jun 2007 12:55
Thanks so much WOLF - works a treat now....

Thanks again

Danny