first blood
This commit is contained in:
1 parent
11b8e5136d
commit
8623958378
124 files changed
+5933
No files matched your search
@@ -0,0 +1,158 @@
|
||||
package fishrungames.doublehitballs;
|
||||
|
||||
import fishrungames.engine.FileWrapper;
|
||||
|
||||
//Deprecated
|
||||
//import fishrungames.doublehitballs.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
//Deprecated
|
||||
//import java.lang.reflect.Field;
|
||||
|
||||
|
||||
public class GL2JNIActivity extends Activity
|
||||
{
|
||||
|
||||
GLView mView;
|
||||
|
||||
boolean IsScrolling = false;
|
||||
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle)
|
||||
{
|
||||
|
||||
super.onCreate(icicle);
|
||||
|
||||
gestureDetector = new GestureDetector(new MyGestureListener());
|
||||
|
||||
FileWrapper.LoadHalibutEngineLibrary();
|
||||
FileWrapper.SetActivityInstance(this);
|
||||
FileWrapper.SetupEnviroment();
|
||||
/*
|
||||
* Deprecated
|
||||
try
|
||||
|
||||
{
|
||||
for (Field f : R.raw.class.getFields())
|
||||
{
|
||||
FileWrapper.AddToFileMap(f.getName(), f.getInt(null));
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
FileWrapper.ConsoleOut("IllegalArgumentException\n");
|
||||
onStop();
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
FileWrapper.ConsoleOut("IllegalAccessException\n");
|
||||
onStop();
|
||||
}*/
|
||||
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = this.getPackageManager();
|
||||
try {
|
||||
appInfo = packMgmr.getApplicationInfo("fishrungames.doublehitballs", 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
|
||||
FileWrapper.SetupApkFilePath(apkFilePath);
|
||||
|
||||
mView = new GLView(getApplication());
|
||||
|
||||
setContentView(mView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
FileWrapper.ConsoleOut("OnPause\n");
|
||||
JniWrapper.StopSounds();
|
||||
super.onPause();
|
||||
mView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
mView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
||||
//FileWrapper.ConsoleOut("OnStop\n");
|
||||
//StopSounds();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
public boolean onTouchEvent (MotionEvent event)
|
||||
{
|
||||
if (gestureDetector.onTouchEvent(event))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event.getAction() == MotionEvent.ACTION_UP)
|
||||
{
|
||||
float x = event.getX();
|
||||
float y = (float)mView.getHeight()-event.getY();
|
||||
|
||||
if(IsScrolling)
|
||||
{
|
||||
IsScrolling = false;
|
||||
}
|
||||
|
||||
JniWrapper.OnTapUp(x, y, event.getEventTime());
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
class MyGestureListener extends SimpleOnGestureListener
|
||||
{
|
||||
@Override
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
|
||||
{
|
||||
JniWrapper.OnFling(velocityX, velocityY, e2.getEventTime());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
|
||||
{
|
||||
JniWrapper.OnScroll(distanceX, distanceY, e2.getEventTime());
|
||||
IsScrolling = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onDown(MotionEvent event)
|
||||
{
|
||||
|
||||
float x = event.getX();
|
||||
float y = (float)mView.getHeight()-event.getY();
|
||||
|
||||
JniWrapper.OnTapDown(x, y, event.getEventTime());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package fishrungames.doublehitballs;
|
||||
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import fishrungames.engine.GLViewAncestor;
|
||||
|
||||
class GLView extends GLViewAncestor
|
||||
{
|
||||
static long lastTimeStamp;
|
||||
static boolean gameIsInited = false;
|
||||
|
||||
public GLView(Context context)
|
||||
{
|
||||
//Change this method? Don't forget to change method below!
|
||||
super(context);
|
||||
init(false, 0, 0);
|
||||
}
|
||||
|
||||
public GLView(Context context, boolean translucent, int depth, int stencil)
|
||||
{
|
||||
//Change this method? Don't forget to change method above!
|
||||
super(context);
|
||||
init(translucent, depth, stencil);
|
||||
}
|
||||
|
||||
public void init(boolean translucent, int depth, int stencil)
|
||||
{
|
||||
super.init(translucent, depth, stencil);
|
||||
setRenderer(new Renderer());
|
||||
Calendar c = Calendar.getInstance();
|
||||
lastTimeStamp = c.getTimeInMillis();
|
||||
gameIsInited = true;
|
||||
}
|
||||
|
||||
private static class Renderer implements GLSurfaceView.Renderer
|
||||
{
|
||||
public void onDrawFrame(GL10 gl)
|
||||
{
|
||||
if (gameIsInited)
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
long currentTimeStamp = c.getTimeInMillis();
|
||||
|
||||
JniWrapper.Update(currentTimeStamp - lastTimeStamp);
|
||||
|
||||
lastTimeStamp = currentTimeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height)
|
||||
{
|
||||
if (JniWrapper.IsInited() == 1)
|
||||
{
|
||||
JniWrapper.Destroy();
|
||||
}
|
||||
JniWrapper.Init(width,height);
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
||||
{
|
||||
//Do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package fishrungames.doublehitballs;
|
||||
|
||||
public class JniWrapper
|
||||
{
|
||||
static {
|
||||
System.loadLibrary("gl2jni");
|
||||
}
|
||||
|
||||
|
||||
public static native void Init(int width, int height);
|
||||
public static native void Update(long dt);
|
||||
public static native void StopSounds();
|
||||
public static native void Destroy();
|
||||
public static native int IsInited();
|
||||
public static native void OnTapDown(float x, float y, long time);
|
||||
public static native void OnTapUp(float x, float y, long time);
|
||||
public static native void OnTapMove(float x, float y, long time);
|
||||
|
||||
public static native void OnFling(float velocityX, float velocityY, long time);
|
||||
public static native void OnScroll(float distanceX, float distanceY, long time);
|
||||
}
|
||||
Reference in new issue
Block a user