⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avatar.java

📁 Critter_Crunch_J2ME 游戏源
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
         if(m_timer == 0) {
            m_state &= ~STATE_EATING;
            setAnim(Anims.BIGGS_IDLE_LEFT);
         }
      }
      if( ((m_state & STATE_CHOMP) != 0) ) {
         if(m_timer == 0) {
            m_state &= ~STATE_CHOMP;
            setAnim(Anims.BIGGS_IDLE_LEFT);
         }
      }
      if( ((m_state & STATE_DROP_BOARD) != 0) ) {
         if(m_timer == 0) {
            //#ifndef NO_SCREEN_SHAKING
            Engine.clearAllShakes();
            //#endif
            
            //#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Nokia_3220 || Nokia_3220_Unobfuscated || Razr
            Level.alterBoard(Level.BOARD_IDLE);
            //#endif
            
            m_state &= ~(STATE_DROP_BOARD | STATE_IMMOBILE);
            setAnim(Anims.BIGGS_IDLE_LEFT);
         }
      }
      if( ((m_state & STATE_SPIT) != 0) ) {
         if(m_timer == 0) {
            m_state &= ~(STATE_SPIT | STATE_IMMOBILE);
            setAnim(Anims.BIGGS_IDLE_LEFT);
         }
      }
      if( ((m_state & STATE_TONGUE_DRAG) != 0) ) {
         m_tongue -= SPEED_TONGUE;
         
         if(m_in_mouth != null) m_in_mouth.m_y += SPEED_TONGUE;

         if(m_tongue <= 0) {
            m_state &= ~(STATE_IMMOBILE | STATE_TONGUE_DRAG);
            
            if(m_in_mouth != null) {
               m_in_mouth.pickup(m_tongue);
            }
            else {
               setAnim(Anims.BIGGS_IDLE_LEFT);
            }
            
            m_tongue = 0;
         }
      }
      if( ((m_state & STATE_TONGUE_FLICK) != 0) ) {
         m_tongue += SPEED_TONGUE;
         
         int [] tongue_box = { m_x + TONGUE_X, m_y + TONGUE_Y - m_tongue, m_x + TONGUE_X + TONGUE_W, m_y + TONGUE_Y };
         int [] tmp_box;
         boolean found_priority = false;

         if(!found_priority) {
            for(int i = 0; i < Level.MAX_EXTRAS; i++) {
               c = Level.s_extras[i];

               if(c != null && c.m_type == Critter.TYPE_ITEM && (c.m_board_x == m_board_x || c.m_board_x == Engine.FULL_INT)) {
                  found_priority = true;
                  tmp_box = c.getBox();
                  
                  if(Engine.collide(tmp_box, tongue_box)) {
                     tongueGrab(c, tmp_box[BOX_HEIGHT]);
                     break;
                  }
               }
            }
         }

         if(!found_priority) {
            c = Level.getLowest(m_board_x);
            
            if(c != null && c.m_y > BIGGS_TONGUE_Y) {
               tmp_box = c.getBox();
               if(Engine.collide(tmp_box, tongue_box)) {
                  tongueGrab(c, tmp_box[BOX_HEIGHT]);
               }
            }
         }
         
         if(m_tongue >= m_destination_tongue) {
            m_tongue = m_destination_tongue;
            m_state &= ~STATE_TONGUE_FLICK;
            m_state |= STATE_TONGUE_DRAG;
         }
      }

      // process toxic guy in mouth.
      if(m_in_mouth != null && m_in_mouth.m_type == Critter.TYPE_CREATURE && 
         ((m_in_mouth.m_state & Critter.STATE_TOXIC) != 0)) {
         
         if(Level.s_state == Level.STATE_ACTIVE) {
            if((Level.s_clock % Critter.TIME_TOXIC_PENALTY) == 0) {
               if(Level.s_type == Level.TYPE_ADVENTURE || Level.s_type == Level.TYPE_TUTORIAL) {
                  //Level.s_level_bar++;

                  //#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Razr
                  if (Level.s_level_bar<Level.s_level_bar_goal) {
                     Particles.create(Particles.TYPE_GOO, Particles.LAYER_HUD, 20,
                        (Level.FOOD_BAR_X+Engine.getRandom(Level.FOOD_BAR_WIDTH))<<Engine.FP_SHIFT, (Level.FOOD_BAR_Y + ((Level.s_level_bar) * Level.FOOD_BAR_MULTIPLYER))<<Engine.FP_SHIFT,
                        0, 0, 0, Engine.getRandom(2<<Engine.FP_SHIFT, 3<<Engine.FP_SHIFT), Particles.getCreatureColor(Critter.CREATURE_TOXIC, 1), Particles.getCreatureColor(Critter.CREATURE_TOXIC, 2));
                  }
                  //#endif
               }
               Level.s_current_score -= Level.TOXIC_MOUTH_POINTS;

               Particles.create(Particles.TYPE_TOXIC_POINTS_TEXT, Particles.LAYER_HUD, (m_x<<Engine.FP_SHIFT), (Level.s_player.m_y - Level.GAME_SQUARE_H)<<Engine.FP_SHIFT, -(Level.TOXIC_MOUTH_POINTS));
            }

            Particles.create(Particles.TYPE_TOXIC_HAZE, Particles.LAYER_FOREGROUND, (m_x<<Engine.FP_SHIFT), (m_y<<Engine.FP_SHIFT), Engine.s_engine.m_state_timer%Particles.TOXIC_HAZE_FRAMES);
         }
         else {
            m_in_mouth = null;
         }
      }
      
      // death animation
      if((m_state & Entity.STATE_DYING) != 0) {
         Particles.create(Particles.TYPE_DEATH_PUFF, 0, m_x<<Engine.FP_SHIFT, m_y<<Engine.FP_SHIFT, 2);
      }
   }

   //#ifndef NO_SCREEN_SHAKING
   // return an offset of the indicated axis based on screen-shaking logic.
   public int shake(int axis) { return Engine.getShake(Engine.SHAKE_BIGGS, axis); }
   //#endif
   
   // process the Avatar's sentencing.
   public void sentence() {}
   
   // process the Avatar's dying sequence.
   public void explode() {}
   
   // process the Avatar's death sequence.
   public void die() {}
   
   // override of Entity pickup.
   public void pickup(int snap) { 
   
      // player-on-player pickup will eventually initiate lifting Biggs up
      // by his tongue.
   }
   
   // return an array representing the on-screen bounding box of the Critter.
   public int [] getBox() {
      
      int x = m_x + S_BOX[BOX_X];
      int y = m_y + S_BOX[BOX_Y];
      int w = x + S_BOX[BOX_WIDTH];
      int h = y + S_BOX[BOX_HEIGHT];
      return new int [] { x, y, w, h };
   }

   // set the indicated animation state.
   public void setAnim(int state) {
      
      //#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Nokia_3220 || Nokia_3220_Unobfuscated || Razr
      if(state == Anims.BIGGS_EATING || 
         state == Anims.BIGGS_CHOMP ||
         state == Anims.BIGGS_FALL ||
         state == Anims.BIGGS_JUMP)     m_anim_state = (short)state;
      else                              m_anim_state = (short)(state + (m_leftside ? 0 : 1));
      //#else 
//#       m_anim_state = (short)state;
      //#endif
      m_frame = 0;
   }
   
   
   
   /****************************************************************************
    ** Miscellaneous Methods
    ***************************************************************************/
   public static final int TONGUE_RGB_LIGHT     = 0xeb5656;
   public static final int TONGUE_RGB_DARK      = 0x9b3d32;
   
   // shoot out Biggs' tongue/breath.
   public void renderBreath(Graphics g, int type) {
      
      Engine.clipScreen(g);
      
      switch(type) {
         
         case BREATH_TONGUE:
            g.setColor(TONGUE_RGB_LIGHT);
            g.fillRect(m_x + TONGUE_X + 1, m_y + TONGUE_Y - m_tongue, TONGUE_W - 2, m_tongue);
            g.setColor(TONGUE_RGB_DARK);
            g.fillRect(m_x + TONGUE_X, m_y + TONGUE_Y - m_tongue, 1, m_tongue);
            g.fillRect(m_x + TONGUE_X + TONGUE_W - 1, m_y + TONGUE_Y - m_tongue, 1, m_tongue);
            g.fillRect(m_x + TONGUE_X + 1, m_y + TONGUE_Y - m_tongue - 1, TONGUE_W - 2, 1);
            
            if(m_in_mouth != null) {
               m_in_mouth.render(g);
               //Engine.clipScreen(g);
               //g.setColor(0, 255, 255);
               //g.drawRect(m_x + TONGUE_X, m_y + TONGUE_Y - m_tongue, TONGUE_W, m_tongue);
               //g.drawRect(m_in_mouth.m_x + Creature.S_BOX[BOX_X], m_in_mouth.m_y + Creature.S_BOX[BOX_Y], Creature.S_BOX[BOX_WIDTH], Creature.S_BOX[BOX_HEIGHT]);
               //#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Nokia_3220 || Nokia_3220_Unobfuscated || Razr
               if (m_in_mouth.m_type == Critter.TYPE_ITEM) {
                  int x_pos = m_in_mouth.m_x;
                  int y_pos = m_in_mouth.m_y +Particles.TONGUE_TIP_RADIUS - Engine.COORDS[Engine.ANIMS[m_in_mouth.m_anim_state][m_in_mouth.m_frame]][Engine.HEIGHT]/2;
                  if (m_in_mouth.m_id==Critter.ITEM_PEPPER || m_in_mouth.m_id==Critter.ITEM_WATERMELON || m_in_mouth.m_id==Critter.ITEM_ONION) {
                     x_pos += Particles.TONGUE_TIP_RADIUS;
                     y_pos += Particles.TONGUE_TIP_RADIUS*2;
                  }
                  Particles.create(Particles.TYPE_TONGUE_TIP, Particles.LAYER_FOREGROUND, 0, x_pos<<Engine.FP_SHIFT, y_pos<<Engine.FP_SHIFT, 0,0,0,0);
               }
               //#endif
            }
            break;
            
         case BREATH_FIRE:
            
            break;
            
         case BREATH_ICE:
            
            break;
            
         case BREATH_ONION:
            
            break;
      }
   }
   
   // grab a Critter with Biggs' tongue.
   public void tongueGrab(Critter c, int destination) {
      
      m_destination_tongue = (short)(m_y + TONGUE_Y - destination);

      if( ((c.m_state & STATE_IMMOBILE) == 0) ) {
         
         //#if DefaultConfiguration || Nokia_6600 || Nokia_6600_Unobfuscated || Nokia_3220 || Nokia_3220_Unobfuscated || Razr
         if(c.m_type == Critter.TYPE_CREATURE) {
            c.setAnim(Anims.GREEN_EATEN);
         }
         else if(c.m_type == Critter.TYPE_ITEM) {
            c.setAnim(Anims.MELON_SNAG);
         }
         //#else
//#          if(c.m_type == Critter.TYPE_CREATURE) {
//#             Engine.playSound(Engine.SOUND_GRAB_CREATURE);
//#          }
//#          else if(c.m_type == Critter.TYPE_ITEM) {
//#             if((c.m_id >= Critter.ITEM_GEM_1 && c.m_id <= Critter.ITEM_GEM_3) || c.m_id == Critter.ITEM_COIN) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -