Skip to content

Instantly share code, notes, and snippets.

View szepi1991's full-sized avatar

David Szepesvari szepi1991

View GitHub Profile
@szepi1991
szepi1991 / terrainAttempt.java
Last active December 10, 2015 13:38
Experimental code to generate a simple polygon based terrain in the Camera view. Code uses AndEngine and the Box2D AndEngine extension.
/**
* Creates a top layer to the cave.. for now simply camera wide and height.
* It is built from trapezoids, so there will be no issue with convexity.
*/
private void createTerrain(final PhysicsWorld pPhysicsWorld,
IEntity attachTo, final Random rand) {
// we'll use this multiple times so let's save a reference here
VertexBufferObjectManager vboMan = this.getVertexBufferObjectManager();
@szepi1991
szepi1991 / removeBody.java
Created January 3, 2013 20:15
Remove a body from the game in AndEngine. This needs to be done on the updateThread. Code from: http://www.matim-dev.com/remove-body-completely.html
final PhysicsConnector physicsConnector =
physicsWorld.getPhysicsConnectorManager().findPhysicsConnectorByShape(shape);
mEngine.runOnUpdateThread(new Runnable()
{
@Override
public void run()
{
if (physicsConnector != null)
{
@szepi1991
szepi1991 / updateThreadExample.java
Last active December 10, 2015 15:38
Illustration of the reversed order of updates on the UpdateThread in AndEngine.
mEngine.runOnUpdateThread(new Runnable() {
@Override
public void run() { Debug.d("Message 1") }
});
mEngine.runOnUpdateThread(new Runnable() {
@Override
public void run() { Debug.d("Message 2") }
});