Android Open Source - Phylane Plane






From Project

Back to project page Phylane.

License

The source code is released under:

COPYRIGHT 2014 TRISTON JONES

If you think the Android project Phylane 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.lvadt.phylane.model;
//  w ww .  j  a v a  2  s  .c om
import android.graphics.Rect;

import com.lvadt.phylane.graphics.Sprite;
import com.lvadt.phylane.model.Objects.Engine;
import com.lvadt.phylane.model.Objects.Material;
import com.lvadt.phylane.model.Objects.Size;
import com.lvadt.phylane.model.Objects.Special;

import java.util.ArrayList;
import java.util.List;

public class Plane{

  
  private GameObject engine;
  private GameObject material;
  private GameObject size;
  private GameObject[] specials;
  static private Sprite sprite;
  
  //Bounding box
  Rect box;
  
  //Physics Stuff, so no specific getters/setters because it would just be tedious and purposeless
  public float x;                  //The x and y positions of the plane on the screen
  public float y;
  public float lastX;
  public float lastY;
  public float velX, velY;              //The velocity in the x and y directions
  public double thrust;                 //Force of the planes forward direction
  public double angle = 11 * (Math.PI / 180);     //In radians angle of flight
  public double lift;                 //Planes actual upward force - its weight
  public double weight;

    /**
     * Create a new plane object
     * @param e its engine
     * @param m its material
     * @param s its size
     */
  public Plane(GameObject e, GameObject m, GameObject s){
    engine = e;
    material = m;
    size = s;
    //Just in case any specials are not defined
    specials = new GameObject[]{Special.NONE.getObj()};
  }

  public void setSprite(Sprite s){
    sprite = s;
  }

  public Sprite getSprite(){
    return sprite;
  }

    /**
     * "Equips" the specified object
     * @param o the object
     * @param t the objects type
     */
    public void set(GameObject o, Objects.Types t){
        switch(t){
            case ENGINE:
                engine = o;
            case MATERIAL:
                material = o;
            case SIZE:
                size = o;
            case SPECIAL:
                //   currentSpecials = Special.values()[x];
        }
    }

    /**
     * "Equips" an array of objects
     * @param o the objects
     * @param t their types
     */
    public void set(GameObject o[], Objects.Types t[]){
        List<GameObject> sp = new ArrayList<GameObject>();
        for(int i = 0; i < t.length; i++){
            switch(t[i]){
                case ENGINE:
                    engine = o[i];
                case MATERIAL:
                    material = o[i];
                case SIZE:
                    size = o[i];
                case SPECIAL:
                    sp.add(o[i]);
            }
        }
        //Convert specials to array
        specials = sp.toArray(new GameObject[sp.size()]);
        sp.clear();
    }
  
  public GameObject getEngine(){
    return engine;
  }
  
  public GameObject getMaterial(){
    return material;
  }
  
  public GameObject getSize(){
    return size;
  }
  
  public GameObject[] getSpecials(){
    return specials;
  }
  
}




Java Source Code List

com.lvadt.phylane.BuildConfig.java
com.lvadt.phylane.activity.Fly.java
com.lvadt.phylane.activity.HomeScreen.java
com.lvadt.phylane.activity.LevelComplete.java
com.lvadt.phylane.activity.LoadScreen.java
com.lvadt.phylane.activity.MainMenu.java
com.lvadt.phylane.activity.MessagePopup.java
com.lvadt.phylane.activity.Prefs.java
com.lvadt.phylane.activity.Splash.java
com.lvadt.phylane.activity.Store.java
com.lvadt.phylane.activity.Tutorial.java
com.lvadt.phylane.graphics.GLRenderer.java
com.lvadt.phylane.graphics.Sprite.java
com.lvadt.phylane.model.GameObject.java
com.lvadt.phylane.model.Level.java
com.lvadt.phylane.model.LoadingScreens.java
com.lvadt.phylane.model.Objects.java
com.lvadt.phylane.model.Plane.java
com.lvadt.phylane.model.Player.java
com.lvadt.phylane.model.WorldObject.java
com.lvadt.phylane.physics.Physics.java
com.lvadt.phylane.utils.Data.java
com.lvadt.phylane.utils.OnSwipeTouchListener.java
com.lvadt.phylane.utils.Sound.java