Skip to content

Instantly share code, notes, and snippets.

@Tom-Ski
Created January 7, 2014 11:13
Show Gist options
  • Save Tom-Ski/8297936 to your computer and use it in GitHub Desktop.
Save Tom-Ski/8297936 to your computer and use it in GitHub Desktop.
Pooled objects
public TempBodyPool(final World world, final Level level) {
toastParticles = new Pool<ToastParticle>() {
@Override
protected ToastParticle newObject() {
return new ToastParticle(world, 1, 1f, 1f, 1, 0.5f, 0.2f);
}
};
cerealParticles = new Pool<CerealParticle>() {
@Override
protected CerealParticle newObject() {
return new CerealParticle(world, 2, 0.3f, 0.3f, 1, 0.5f, 0.2f);
}
};
owParticles = new Pool<OwParticle>() {
@Override
protected OwParticle newObject() {
float sizeX = rand.nextInt(10) / 10;
float sizeY = rand.nextInt(10) / 10;
return new OwParticle(world, 2, 1f + sizeX, 0.5f + sizeY, 0.2f + (rand.nextFloat() / 5), level.getWordBank().getRandomWord());
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment