My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
CodeSnipplets  
Code snipplets.
Updated Feb 4, 2010 by assuncas

Introduction

This page shows how to perform a variety of tasks with the engine. For method call details, use your IDE :)

Content

Initializing the engine

Done typically in the constructor of a class that implements EngineInterface.

engine = Engine.getInstance();
engine.init(WIDTH, HEIGHT, DEPTH, FULLSCREEN, this);
engine.start();

Detecting a key press (inside the checkKeys method)

if (engine.isKeyPressed(Keyboard.KEY_ADD)) {
  // Your action here
}

Drawing text

font = new GLFont("resources/fonts/tahoma.png", 1.0f);
font.print("FPS: " + engine.getFPS(), 10, 10, 1.0f, GLColor.GREEN);

Loading an image

crate = new GLImage("resources/images/crate.jpg");

Showing flying text

flyingText = new GLFlyingText("Critical!", font, 1000, true, 100, 0.8f, 1.5f);

Loading an animated image

character = new GLAnimatedImage("resources/images/character.png", 64, 64, 64, 64, 4);
character.setUpdateInterval(200);
character.setAnimationLoop(true);

Creating an explosion

particleExplosion = new GLParticleSystemExplode();
particleExplosion.initParticles("resources/images/particle.png", 100);
particleExplosion.setRadius(0, 50);
particleExplosion.setSpeed(0.1f, 3);
particleExplosion.setTimeToLive(4000, 5000);

Drawing image with rotation around its center axis

crate.drawRotated(400, 100, 45.0f);

More examples

For these and more examples, see the engine test class: http://code.google.com/p/oje2d/source/browse/trunk/src/main/java/org/voidness/oje2d/tests/EngineTest.java


Sign in to add a comment
Powered by Google Project Hosting