Android Open Source - TreeFrogEngine Android Game






From Project

Back to project page TreeFrogEngine.

License

The source code is released under:

MIT License

If you think the Android project TreeFrogEngine 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.discretesoftworks.framework;
//w  w w.  ja  v a 2 s  .c o  m

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;

import com.discretesoftworks.zRTS.R;


// AndroidGame
// Initial class for running an Android Game.
// Is both the Activity and the Context.
public abstract class AndroidGame extends Activity{

    private GLSurfaceView mGLView;     // View
    private GameController controller;  // Controller
    
    public static AndroidGame s_instance;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        Log.i("Android","Begin");
        
        s_instance = this;
        
        // Set fullscreen with no title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Create our GLSurface
        //mGLView = new MyGLSurfaceView(this,this);
        setContentView(R.layout.game);
    }

    public void getInput(final TextHolder td, final String promptA, final String promptB){
      
      final Activity activity = this;
      final EditText input = new EditText(this);
      
      this.runOnUiThread(new Runnable() {
        public void run() {
          new AlertDialog.Builder(activity)
          .setTitle(promptA)
          .setMessage(promptB)
          .setView(input)
          .setPositiveButton("OK", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) { 
                td.setText(input.getText().toString());
              }
          })
          .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              td.setText(getString(R.string.emptyString));
            }
          }
          ).show();
        }
    }
      );
    }
    
    @Override
  public void onResume() {
      System.out.println("Resuming.");
    super.onResume();
  }
  
  @Override
  public void onPause() {
    System.out.println("Pausing.");
    super.onPause();
  }
  
  public GameController getController(){
    return controller;
  }
  
  public GLSurfaceView getMyGLSurfaceView(){
    return mGLView;
  }
  
  public void setController(GameController controller){
    GameRenderer.s_instance.clear();
    this.controller = null;
    this.controller = controller;
    System.gc(); // Do a garbage clean when we change controllers
  }
}




Java Source Code List

com.discretesoftworks.OUYAframework.OuyaGameController.java
com.discretesoftworks.OUYAframework.OuyaGame.java
com.discretesoftworks.TestGame.Floor.java
com.discretesoftworks.TestGame.Player.java
com.discretesoftworks.TestGame.Pointer.java
com.discretesoftworks.TestGame.TestController.java
com.discretesoftworks.TestGame.TestGame.java
com.discretesoftworks.framework.AndroidGame.java
com.discretesoftworks.framework.Assets.java
com.discretesoftworks.framework.Directional.java
com.discretesoftworks.framework.GameController.java
com.discretesoftworks.framework.GameFont.java
com.discretesoftworks.framework.GameObject.java
com.discretesoftworks.framework.GameRenderer.java
com.discretesoftworks.framework.GriddedObject.java
com.discretesoftworks.framework.ModelLoader.java
com.discretesoftworks.framework.MovingObject.java
com.discretesoftworks.framework.MyGLRenderer.java
com.discretesoftworks.framework.MyGLSurfaceView.java
com.discretesoftworks.framework.NumericalMatrix.java
com.discretesoftworks.framework.Pair.java
com.discretesoftworks.framework.Path.java
com.discretesoftworks.framework.Pool.java
com.discretesoftworks.framework.RaggedDictionary.java
com.discretesoftworks.framework.RenderModel.java
com.discretesoftworks.framework.Sprite.java
com.discretesoftworks.framework.Terrain.java
com.discretesoftworks.framework.TextDisplay.java
com.discretesoftworks.framework.TextHolder.java
com.discretesoftworks.framework.View.java
com.discretesoftworks.networking.NetworkGameController.java
com.discretesoftworks.networking.Writer.java