My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
MinimalThing  
This is the minimal code to use the engine
Updated Feb 4, 2010 by assuncas

Minimal code

Just start with something like the following code:

package org.voidness.oje2d.tests;

import org.lwjgl.input.Keyboard;
import org.voidness.oje2d.Engine;
import org.voidness.oje2d.interfaces.EngineInterface;

public class SimplerEngineTest implements EngineInterface {

    public SimplerEngineTest() {

        Engine.getInstance().init(640, 480, 32, false, this);
        Engine.getInstance().start();
    }

    public void initChild() {

        // This is where you initialize your stuff (resources, objects, etc.)
    }

    public void checkKeys() {

        // This method will be called every cycle.

        if (Engine.getInstance().isKeyPressed(Keyboard.KEY_ESCAPE)) {
            Engine.getInstance().destroy();
            System.exit(0);
        }
    }

    public void render() {

        // This is where you should render your images
    }

    public void onEngineExit() {

        // Before exiting, the engine will call this method
    }

    public void mousePressed(int mButton) {

        // Everytime a mouse button is pressed, this is called
    }

    public void mouseReleased(int mButton) {

        // Everytime a mouse button is released, this is called
    }

    public static void main(String[] args) {
        
        // Don't forget the java.library.path on your run configuration. It 
        // needs to point to wherever you have your LWJGL binaries.
        // Something like this:
        // -Djava.library.path=/Users/void/Development/lwjgl-2.1.0/native/macosx
        new SimplerEngineTest();
    }
}

Sign in to add a comment
Powered by Google Project Hosting