Package dwlab.behavior_models

Examples of dwlab.behavior_models.AnimationModel


    addToStack( hurtingAnimation );
    addToStack( punchingAnimation );
    addToStack( kickingAnimation );

    jumpingAnimation = new AnimationModel( false, jumpingAnimationSpeed, 2, 8 );
    addToStack( jumpingAnimation );

    fallingAnimation = new AnimationModel( true, jumpingAnimationSpeed, 1, 10 );
    jumpingAnimation.nextModels.addLast( new ModelActivator( fallingAnimation ) );
    addToStack( fallingAnimation );

    addToStack( movementAnimation );


    attachModel( movementControl );


    IsButtonActionDown jumpKeyDown = IsButtonActionDown.create( jumpKey );
    attachModel( jumpKeyDown );
    jumpKeyDown.falseModels.addLast( jumpKeyDown );

    IsModelActive onLandCondition = new IsModelActive( onLand );
    jumpKeyDown.trueModels.addLast( onLandCondition );

    onLandCondition.trueModels.addLast( new ModelActivator( jumpingAnimation ) );
    onLandCondition.trueModels.addLast( new ModelDeactivator( gravity ) );
    onLandCondition.falseModels.addLast( jumpKeyDown );

    FixedWaitingModel pauseBeforeJump = FixedWaitingModel.create( jumpingPause );
    pauseBeforeJump.nextModels.addLast( new Jump( jumpingStrength, jumpingStrength ) );
    pauseBeforeJump.nextModels.addLast( new ModelActivator( gravity ) );
    pauseBeforeJump.nextModels.addLast( jumpKeyDown );
    onLandCondition.trueModels.addLast( pauseBeforeJump );

    addToStack( jumpingAnimation, false );


    IsButtonActionDown hitKeyDown = IsButtonActionDown.create( hitKey );
    attachModel( hitKeyDown );
    hitKeyDown.falseModels.addLast( hitKeyDown );

    IsModelActive hitPauseCondition = new IsModelActive( hitPause );
    hitPauseCondition.falseModels.addLast( hitPause );
    hitPauseCondition.trueModels.addLast( hitKeyDown );
    hitKeyDown.trueModels.addLast( hitPauseCondition );

    IsModelActive onLandCondition2 = new IsModelActive( onLand );
    onLandCondition2.trueModels.addLast( new ModelActivator( punchingAnimation ) );
    onLandCondition2.trueModels.addLast( new HittingArea( true ) );
    onLandCondition2.trueModels.addLast( hitKeyDown );
    onLandCondition2.falseModels.addLast( new ModelActivator( kickingAnimation ) );
    onLandCondition2.falseModels.addLast( new HittingArea( false ) );
    onLandCondition2.falseModels.addLast( hitKeyDown );
    hitPauseCondition.falseModels.addLast( onLandCondition2 );


    addToStack( new AnimationModel( true, idleAnimationSpeed, 4, 0, true ) );
  }
View Full Code Here


    attachModelImmediately( new ModelDeactivator( onLand, true ) );
   
    addTileMapCollisions( Group.HORIZONTAL, instance.tileMap, bumpingWalls, null );
    addTileMapCollisions( Group.VERTICAL, instance.tileMap, verticalCollisionHandler, null );

    jumpingAnimation = new AnimationModel( false, jumpingAnimationSpeed, 8, 8 );
    fallingAnimation = new AnimationModel( true, jumpingAnimationSpeed, 3, 13, true );
    AnimationModel firingAnimation = new AnimationModel( false, firingAnimationSpeed, 8, 16 );


    if( parameterExists( "jumping" ) ) {
      double[] parameters= getDoubleParameters( "jumping", "-" );
      RandomWaitingModel waitingForJump = new RandomWaitingModel( parameters[ 0 ], parameters[ 1 ] );
      attachModel( waitingForJump );

      IsModelActive onLandCondition = new IsModelActive( onLand );
      waitingForJump.nextModels.addLast( onLandCondition );

      IsModelActive animationActive = new IsModelActive( firingAnimation );
      onLandCondition.trueModels.addLast( animationActive );
      onLandCondition.falseModels.addLast( waitingForJump );

      animationActive.trueModels.addLast( waitingForJump );
      animationActive.falseModels.addLast( new ModelActivator( jumpingAnimation ) );
      animationActive.falseModels.addLast( new ModelDeactivator( horizontalMovementModel() ) );
      animationActive.falseModels.addLast( new ModelDeactivator( gravity ) );

      jumpingAnimation.nextModels.addLast( new ModelActivator( fallingAnimation ) );

      parameters= getDoubleParameters( "jumping_strength", "-" );
      FixedWaitingModel pauseBeforeJump = FixedWaitingModel.create( jumpingPause );
      pauseBeforeJump.nextModels.addLast( new Jumpparameters[ 0 ], parameters[ 1 ] ) );
      pauseBeforeJump.nextModels.addLast( new ModelActivator( horizontalMovementModel() ) );
      pauseBeforeJump.nextModels.addLast( new ModelActivator( gravity ) );
      pauseBeforeJump.nextModels.addLast( waitingForJump );
      animationActive.falseModels.addLast( pauseBeforeJump );

      addToStack( jumpingAnimation );
      score += 200;
    }


    addToStack( fallingAnimation );


    if( parameterExists( "firing" ) ) {
      double[] parameters = getDoubleParameters( "firing", "-" );
      RandomWaitingModel waitingForFire = new RandomWaitingModel( parameters[ 0 ], parameters[ 1 ] );
      attachModel( waitingForFire );

      IsModelActive onLandCondition = new IsModelActive( onLand );
      waitingForFire.nextModels.addLast( onLandCondition );

      IsModelActive animationActive = new IsModelActive( jumpingAnimation );
      onLandCondition.trueModels.addLast( animationActive );
      onLandCondition.falseModels.addLast( waitingForFire );

      animationActive.trueModels.addLast( waitingForFire );
      animationActive.falseModels.addLast( new ModelActivator( firingAnimation ) );
      animationActive.falseModels.addLast( new ModelDeactivator( horizontalMovementModel() ) );

      firingAnimation.nextModels.addLast( new ModelActivator( horizontalMovementModel() ) );

      parameters = getDoubleParameters( "firing_speed", "-" );
      FixedWaitingModel pauseBeforeBullet = FixedWaitingModel.create( bulletPause );
      pauseBeforeBullet.nextModels.addLast( new CreateBullet( parameters[ 0 ], parameters[ 1 ] ) );
      pauseBeforeBullet.nextModels.addLast( waitingForFire );
      animationActive.falseModels.addLast( pauseBeforeBullet );

      addToStack( firingAnimation, false );
      score += 300;
    }

    AnimationModel movementAnimation = new AnimationModel( true, walkingAnimationSpeed, 3, 3, true );
    if( parameterExists( "moving" ) ) {
      double[] parameters = getDoubleParameters( "moving", "-" );
      dX = Math.signum( visualizer.xScale ) * Service.random( parameters[ 0 ], parameters[ 1 ] );
      addToStack( movementAnimation );
      score += 100;
    } else {
      dX = 0;
    }
   

    AnimationModel standingAnimation = new AnimationModel( true, idleAnimationSpeed, 3, 0, true );
    addToStack( standingAnimation );

    if( parameterExists( "score" ) ) score = getIntegerParameter( "score" );
    if( parameterExists( "health" ) ) health = getDoubleParameter( "health" );
  }
View Full Code Here

TOP

Related Classes of dwlab.behavior_models.AnimationModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.