Android Open Source - catchanimals Basket






From Project

Back to project page catchanimals.

License

The source code is released under:

GNU General Public License

If you think the Android project catchanimals listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ricardorb.sprites;
/* w  w  w.  j a  v a2 s . c o m*/
import com.badlogic.gdx.Gdx;
import com.ricardorb.catchanimals.Assets;
import com.ricardorb.catchanimals.CatchAnimals;
import com.ricardorb.controllers.ControllerBasket;
/**
 * Bucket of the game, the user will move the bucket in the game
 * 
 * @author RicardoRB
 *
 */
public class Basket extends com.ricardorb.sprites.Element{
  
  private static final int BUCKETVELX = 200;
  private ControllerBasket conBucket;
  
  
  public Basket(final CatchAnimals game, ControllerBasket conBucket) {
    super(Assets.basket,game);
    setPosition(game.WINDOWX / 2 - getWidth() / 2, 20f);
    setCenter(getWidth() / 2, getHeight() / 2);
    this.conBucket = conBucket;
  }
  
  public void update(){
    
    //Move the bucket
    if(conBucket.isMoveR()){
      setX(getX() + BUCKETVELX * Gdx.graphics.getDeltaTime());
    }else if(conBucket.isMoveL()){
      setX(getX() - BUCKETVELX * Gdx.graphics.getDeltaTime());
    }else if(conBucket.isDrag()){
      setPosition(conBucket.getDragX(), getY());
    }
    
    //Bucket cant get out of the screen
    if (getX() < 0) {
      setX(0);
    }
    
    if (getX() > GAME.WINDOWX - getWidth()) {
      setX(GAME.WINDOWX - getWidth());
    }
    rectangle.x = getX();
    rectangle.y = getY();
  }

  public static int getBucketvelx() {
    return BUCKETVELX;
  }
  
}




Java Source Code List

com.ricardorb.catchanimals.Assets.java
com.ricardorb.catchanimals.CatchAnimals.java
com.ricardorb.catchanimals.android.AndroidLauncher.java
com.ricardorb.catchanimals.desktop.DesktopLauncher.java
com.ricardorb.controllers.ControllerBasket.java
com.ricardorb.controllers.ControllerOption.java
com.ricardorb.inputs.InputBasket.java
com.ricardorb.screens.GameScreen.java
com.ricardorb.screens.MainMenuScreen.java
com.ricardorb.screens.OptionScreen.java
com.ricardorb.sprites.Animal.java
com.ricardorb.sprites.Basket.java
com.ricardorb.sprites.Element.java