Android Open Source - ZombieBird Scrollable






From Project

Back to project page ZombieBird.

License

The source code is released under:

Apache License

If you think the Android project ZombieBird 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.kilobolt.GameObjects;
//from   w ww .j a  v a 2 s  .c  o  m
import com.badlogic.gdx.math.Vector2;

public class Scrollable {
  
  // Protected is similar to private, but protected allows subclass inheritance
  protected Vector2 position;
  protected Vector2 velocity;
  protected int width;
  protected int height;
  protected boolean isScrolledLeft;
  
  public Scrollable(float x, float y, int width, int height, float scrollSpeed) {
    position = new Vector2(x, y);
    velocity = new Vector2(scrollSpeed, 0);
    this.width = width;
    this.height = height;
    isScrolledLeft = false;
  }
  
  public void update(float delta) {
    position.add(velocity.cpy().scl(delta));
    
    // If the Scrollable object is no longer visible
    if(position.x + width < 0){
      isScrolledLeft = true;
    }
  }
  
  // Reset: this should be overridden in a subclass for detailed behavior
  public void reset(float newX) {
    position.x = newX;
    isScrolledLeft = false;
  }
  
  public boolean isScrolledLeft() {
    return isScrolledLeft;
  }
  
  public float getTailX() {
    return position.x + width;
  }
  
  public float getX() {
    return position.x;
  }
  
  public float getY() {
    return position.y;
  }
  
  public int getWidth() {
    return width;
  }
  
  public int getHeight() {
    return height;
  }

}




Java Source Code List

com.kilobolt.GameObjects.Bird.java
com.kilobolt.GameObjects.Grass.java
com.kilobolt.GameObjects.Pipe.java
com.kilobolt.GameObjects.ScrollHandler.java
com.kilobolt.GameObjects.Scrollable.java
com.kilobolt.GameWorld.GameRenderer.java
com.kilobolt.GameWorld.GameWorld.java
com.kilobolt.Screens.GameScreen.java
com.kilobolt.ZBHelpers.AssetLoader.java
com.kilobolt.ZBHelpers.InputHandler.java
com.kilobolt.ZombieBird.MainActivity.java
com.kilobolt.ZombieBird.Main.java
com.kilobolt.ZombieBird.RobovmLauncher.java
com.kilobolt.ZombieBird.ZBGame.java
com.kilobolt.ZombieBird.client.GwtLauncher.java