Click here to Skip to main content
14,031,046 members
Click here to Skip to main content

Stats

34.5K views
960 downloads
31 bookmarked
Posted 4 Nov 2012
Licenced Apache

Terminal Velocity Android

, 23 May 2013
An android game using NDK JNI and Java.
TerVel
.classpath
.project
.settings
assets
asset.items
bg.pack
bg.png
bg2.png
coin.ogg
cur.ogg
cur.pack
cur.png
cur.wav
f.pack
f.png
gui.pack
gui.png
hero.pack
hero.png
hit.wav
items.pack
items.png
jk.pack
jk.png
m1.mp3
over.pack
over.png
rocket.wav
select.ogg
splash.png
stf.pack
stf.png
strike.pack
strike.png
Thumbs.db
bin
classes
com
badlogic
androidgames
framework
Audio.class
Color.class
DynamicGameObject.class
FileIO.class
Game.class
GameObject.class
gl
Animation.class
Camera2D.class
Font.class
FPSCounter.class
SpatialHashGrid.class
SpriteBatcher.class
Texture.class
TextureRegion.class
Vertices.class
Graphics$PixmapFormat.class
Graphics.class
impl
AccelerometerHandler.class
AndroidAudio.class
AndroidFastRenderView.class
AndroidFileIO.class
AndroidGame.class
AndroidGraphics.class
AndroidInput.class
AndroidMusic.class
AndroidPixmap.class
AndroidSound.class
GLGame$GLGameState.class
GLGame.class
GLGraphics.class
GLScreen.class
KeyboardHandler$1.class
KeyboardHandler.class
MultiTouchHandler$1.class
MultiTouchHandler.class
SingleTouchHandler$1.class
SingleTouchHandler.class
TouchHandler.class
Input$KeyEvent.class
Input$TouchEvent.class
Input.class
math
Circle.class
OverlapTester.class
Rectangle.class
Vector2.class
Music.class
Pixmap.class
Pool$PoolObjectFactory.class
Pool.class
Screen.class
Sound.class
TestScreen.class
inductionlabs
jni
bridge
BatcherBridge.class
Bridge.class
tools_seting_bridge.class
tervel
Assets$1.class
Assets$2.class
Assets.class
BuildConfig.class
Datastore.class
GameScreen.class
loaderparser.class
NativeFun.class
R$attr.class
R$drawable.class
R.class
resumescreen.class
Settings.class
TerVel.class
texturenameinfo.class
TexturRegionName.class
libgdxextension
FontExtension.class
GLGame$GLGameState.class
GLGame.class
GLGraphics.class
spritebatchextension.class
classes.dex
jarlist.cache
res
drawable-hdpi
tv.png
gen
inductionlabs
tervel
ic_launcher-web.png
jni
drawparts
engine
GameData
ViewManager
libgdx.jar
libs
armeabi
gdb.setup
gdbserver
libengine.so
armeabi-v7a
x86
gdb.setup
gdbserver
libengine.so
obj
local
armeabi
app_process
libc.so
libengine.so
libstdc++.a
objs-debug
engine
engine
Game.o
GameData
GameData.o
ViewManager
ViewManager.o
x86
app_process
libc.so
libengine.so
libstdc++.a
objs-debug
engine
engine
Game.o
GameData
GameData.o
ViewManager
ViewManager.o
res
drawable-hdpi
tv.png
src
com
badlogic
androidgames
framework
gl
impl
math
inductionlabs
jni
bridge
tervel
libgdxextension
package inductionlabs.tervel;


import java.util.List;
import inductionlabs.jni.bridge.BatcherBridge;
import inductionlabs.jni.bridge.Bridge;
import inductionlabs.jni.bridge.tools_seting_bridge;

import javax.microedition.khronos.opengles.GL10;

import libgdxextension.spritebatchextension;

import android.app.Activity;
import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Input.KeyEvent;
import com.badlogic.androidgames.framework.Input.TouchEvent;
import com.badlogic.androidgames.framework.gl.Camera2D;
import com.badlogic.androidgames.framework.gl.FPSCounter;
import com.badlogic.androidgames.framework.gl.Texture;
import com.badlogic.androidgames.framework.gl.TextureRegion;
import com.badlogic.androidgames.framework.impl.GLScreen;
import com.badlogic.androidgames.framework.math.Rectangle;
import com.badlogic.androidgames.framework.math.Vector2;

public class GameScreen extends GLScreen
{
	Camera2D guiCam;
    public  spritebatchextension batcher;
    public  BatcherBridge batcherBridge;
    public  tools_seting_bridge ts_bridge;
    
    Rectangle nextBounds;
    Vector2 touchPoint;
    Texture helpImage;
    TextureRegion helpRegion;
    FPSCounter f;
	private boolean first;
	private boolean resume=false;
    public GameScreen(Game game)
  {
    	
    	super(game);
        guiCam = new Camera2D(glGraphics, Assets.screenWidth, Assets.screenHeight);
        batcher = new spritebatchextension(glGraphics,Assets.max_texrg );
        batcherBridge=new BatcherBridge(batcher);
        ts_bridge=new tools_seting_bridge();
        f=new FPSCounter();
        //Sending a handle of this class to c++
        Bridge.object(this, 0);
       //Sending a handle of this class to c++
        Bridge.object(batcherBridge, 1);
       //Sending a handle of this class to c++
        Bridge.object(guiCam, 2);
      //////////////////////////////////////
        Bridge.object(ts_bridge,4);
      /////////////////////////////////  
        
    }
    
    //Resume Call
    @Override
    public void resume()
    {  	
    	if(!resume)
    	NativeFun.preResume();	
    	
    }
    
    
  //Pause Call  
    @Override
    public void pause() 
    {
     Assets.splashscreen.dispose();
     if(Assets.loaderp==100)	
     {
     Assets.dispose();
     }
     resume=true;
     Settings.save(TerVel.fileiohandle);
     NativeFun.prePause();
    }
    //Input Calls
    @Override
    public void update(float deltaTime) 
    {
    	List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
        List<KeyEvent> keyEvents= game.getInput().getKeyEvents();
        
        touchPoint=new Vector2();
        
        
        
        int len = keyEvents.size();
        for(int i = 0; i < len; i++)
        {  KeyEvent event =  keyEvents.get(i);
           Assets.keyhandle=NativeFun.updatekey(event.keyCode,event.type);

          // if(event.keyCode==android.view.KeyEvent.KEYCODE_VOLUME_DOWN)
        	//   ((Activity) TerVel.contex).finish();
          // Assets.keyhandle=true;
           //keyEvents.remove(i);
        }
        len = touchEvents.size();
        
        for(int i = 0; i < len; i++)
        {  TouchEvent event = touchEvents.get(i);
           touchPoint.set(event.x, event.y);
           guiCam.touchToWorld(touchPoint);
           
           Assets.vibrate(Assets.vibra);
          
           
           NativeFun.updatetou(touchPoint.x,touchPoint.y,event.type,event.pointer);
          // touchEvents.remove(i);
         
         }
    
        
    NativeFun.onSensorChanged(game.getInput().getAccelX(),game.getInput().getAccelY(),game.getInput().getAccelZ());
    
    }
    
    
    
    //Draw calls
    @Override
    public void present(float deltaTime) 
    {   GL10 gl = glGraphics.getGL();
    	clrscr(gl);
    	//Screen set and now draw calls from native code
    	
    	if(Assets.loaderp!=100)
    	{drawload(deltaTime,gl);
    	if(resume!=true)
    		first=true;
    	}
    	
    	else
    	{
        if(first)
    	{NativeFun.initEngine();
        first=false;
        }
    	NativeFun.draw(deltaTime);
    	
     
    	}
    	f.logFrame();
    	if(Assets.quit==true)
    	{((Activity) TerVel.contex).finish();
    		
    	}
    	
    }
    static int angle=0;
    static float time=0;
    
    private void drawload(float deltaTime,GL10 gl) 
    {                    
    
    batcher.beginBatch(Assets.splashscreen);
    batcher.drawSprite(160, 240, 320, 480,Assets.loadscreen);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    //batcher.drawSprite(160, 200, 10,156/2,55/2,Assets.loading);
    batcher.drawSprite(50, 50,0+360*Assets.loaderp/100,60,0,Assets.circ);
    time=500*deltaTime;
    
    if(time>2)
    {angle+=5;
     angle%=360;
    time=0;
    }
    batcher.endBatch();
      
	}

	void clrscr(GL10 gl)
    {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    guiCam.setViewportAndMatrices();
    gl.glEnable(GL10.GL_TEXTURE_2D);
    	
    }
    {/*
    void drawbg(GL10 gl)
    {
    batcher.beginBatch(Assets.background);
    batcher.drawSprite(160, 240, 320, 480,Assets.backgroundRegion);
    batcher.endBatch();
    }
    
    void drawfront(GL10 gl)
    {
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    batcher.beginBatch(Assets.items);          
    batcher.drawSprite(320 - 32, 32, -64, 64, Assets.arrow);
    batcher.endBatch();
    gl.glDisable(GL10.GL_BLEND);
    	
    }
    }

    */
    }
	@Override
	public void dispose()
	{
	// TODO Auto-generated method stub
		
	}
    
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

PraveenOjha
Chief Technology Officer InductionLabs
India India
Currently I am an independent developer usually develops under brand name Induction games sometimes under Induction labs ,Can say that I am professionally developing apps for more than 4 years .

Some links to my apps in different apps stores are ..


Windows Phone
http://www.windowsphone.com/en-US/store/publishers?publisherId=InductionGames

Android
1. https://play.google.com/store/apps/developer?id=Induction+Labs&hl=en
2.https://play.google.com/store/apps/developer?id=Induction%20Games

Blackberry Store
http://appworld.blackberry.com/webstore/vendor/39848/?lang=en

Flash Games :
http://www.mochigames.com/developer/praveenojha/
*my flash portal is no longer active so the quiz game cant be played .

Perceptual computing phase 1 first prize Winner app (air piano)
http://software.intel.com/sites/campaigns/perceptualshowcase/air-piano.htm

My Blog
http://praveenojha.com

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190419.4 | Last Updated 23 May 2013
Article Copyright 2012 by PraveenOjha
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid