• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Rokon - 2D OpenGL Game Framework

Frink

Lurker
I've been working on a 2D OpenGL framework for a little while now, with full intentions from the start of being open source. Today I am releasing the first (0.1 alpha) version.

There are bugs, and it isn't as fast as it could be. But it's only the start.

Included are 9 examples, each of which explains how to use different features in the framework.

Currently, the framework supports

  • Texture and Sprite management
  • Text, using TTF fonts
  • Organised layers
  • Two audio management classes, one optimized for music, the other for sound effects
  • Sprite dynamics (acceleration, terminal velocity, collisions)
  • Animation
  • Handlers to manage events fired through movement, animation, screen touches, accelerometer input, device shaking and collisions
  • Several minor features aimed at speeding development, such as screen settings and vibration


The framework is intended to make game development as quick and easy as possible, while still keeping the high frame rates that OpenGL can provide.

I have a google code project for this at rokon - Project Hosting on Google Code and a development blog at Rokon Game Engine

There are many things I have listed which I fully intend to implement, such as more complex physics, tile engines and post processing.

Please let me know of bugs, offer suggestions or improvements. I do not purport to be an OpenGL expert. Infact, until last week, I had never touched any sort of OpenGL in my life.

To show how easy it is to implement, I've pasted one of the examples below. It shows a button and 3 sprites. When the button is pressed, the sprites move at different speeds, one rotation.

Code:
public class Example4 extends Activity {

    Sprite crabSprite1;
    Sprite crabSprite2;
    Sprite crabSprite3;
    Texture crabTexture;
    
    Sprite buttonSprite;
    Texture buttonTexture;

    Rokon rokon;
    Hotspot hotspot;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        rokon = Rokon.createEngine(this);
        rokon.setFullscreen();
        rokon.fixLandscape();
        rokon.init();

        crabTexture = rokon.createTextureFromResource(R.drawable.crab); 
        buttonTexture = rokon.createTextureFromResource(R.drawable.button); 
        rokon.prepareTextureAtlas();

        buttonSprite = new Sprite(5, 5, 100, 50, buttonTexture);
        crabSprite1 = new Sprite(10, 50, 80, 80, crabTexture);
        crabSprite2 = new Sprite(10, 150, 80, 80, crabTexture);
        crabSprite3 = new Sprite(10, 250, 80, 80, crabTexture);
        
        rokon.addSprite(buttonSprite);
        rokon.addSprite(crabSprite1);
        rokon.addSprite(crabSprite2);
        rokon.addSprite(crabSprite3);

        rokon.setInputHandler(new myInputHandler());
        hotspot = new Hotspot(buttonSprite);
        rokon.addHotspot(hotspot);
    }
    
    public class myInputHandler extends InputHandler {
        public void onHotspotTouched(Hotspot hotspot) {
            crabSprite1.setXY(10, 50);
            crabSprite2.setXY(10, 150);
            crabSprite3.setXY(10, 250);

            crabSprite1.resetDynamics();
            crabSprite2.resetDynamics();
            crabSprite3.resetDynamics();

            crabSprite1.accelerate(25, 0);
            crabSprite2.accelerate(50, 0, 100, 0);
            crabSprite3.setVelocity(50, 0);
            
            crabSprite3.resetModifiers();
            crabSprite3.setRotation(0);
            crabSprite3.addModifier(new Spin(1));
        }
    }
}
You can find the first release, 0.1 alpha at Downloads - rokon - Project Hosting on Google Code
 
Hi!, as i posted on your blog, i may become even a FAN of your work hahaha if its good for me, and if else, i will congratulate you for doing something that is incredible help for the community

Thank you!!!

i will comment you about my work with your engine if it moves forward :)

regards

PD: im sure youd love to see some community made games with a splash screen saying "Powered by Rokon" ;D
 
Back
Top Bottom