Hello everyone,
I’m actually developping my own little game, will be a Diablo like game in 2D. I already started the development few month ago using LIBGdx and i’ve got a few question.
I reached a point where i need to handle light. I know there is something added in 1.0.0 who was available as an external librairies before called BOX2DLights. I’ve already used it for another game.
The problem is the following one, BOX2DLight need you to use BOX2D, and my game is top view game (meaning that the camera is on the top of the player, like Pokemon) and doesn’t implements any Box2D stuff. I’m using this code as an Entity and Wall collider :
public boolean collision(float x, float y) {
int posXleft = (int) (x / this.map.tileWidth);
int posYbot = (int) (y / this.map.tileHeight);
int posXright = (int) ((x + collisionWidth) / this.map.tileWidth);
int posYtop = (int) ((y + collisionHeight) / this.map.tileHeight);
if(map.collisionLayer.getCell(posXleft, posYbot).getTile().getProperties().containsKey("blocked")) {
return true;
}
if(map.collisionLayer.getCell(posXleft, posYtop).getTile().getProperties().containsKey("blocked")) {
return true;
}
if(map.collisionLayer.getCell(posXright, posYbot).getTile().getProperties().containsKey("blocked")) {
return true;
}
if(map.collisionLayer.getCell(posXright, posYtop).getTile().getProperties().containsKey("blocked")) {
return true;
}
if(map.collisionLayer.getCell(posXleft, posYbot).getTile().getProperties().containsKey("wall")) {
return true;
}
if(map.collisionLayer.getCell(posXleft, posYtop).getTile().getProperties().containsKey("wall")) {
return true;
}
if(map.collisionLayer.getCell(posXright, posYbot).getTile().getProperties().containsKey("wall")) {
return true;
}
if(map.collisionLayer.getCell(posXright, posYtop).getTile().getProperties().containsKey("wall")) {
return true;
}
return false;
};
protected boolean collisionInEntity(float x, float y, float xObject, float yObject, int collisionHeight, int collisionWidth) {
Rectangle player = new Rectangle(x, y, this.collisionWidth, this.collisionHeight);
ShapeRenderer shapeRenderer = new ShapeRenderer();
shapeRenderer.setProjectionMatrix(map.camera.combined);
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(new Color(0, 1, 0, 1));
shapeRenderer.rect(x, y, this.collisionWidth, this.collisionHeight);
shapeRenderer.end();
Rectangle ennemy = new Rectangle(xObject, yObject, collisionWidth, collisionHeight);
if(player.overlaps(ennemy) || ennemy.overlaps(player)) {
return true;
}
return false;
}
There won’t be anymore collision stuff (i can handle any sort of spell, ennemy or wall and that’s enough for me).
So here is my point. Do i need to rewrite my code to implement Box2D to each of my entities who will allow me to handle Box2DLights ? Do i have another possibility to handle the lights collision why my own collisions ? Is it possible to write my own light stuff ?
Now another question. As i say, i’m currently developping under Libgdx, but as far as i see, the only good point Libgdx offer me is cross platform possibility and for this project i clearly don’t need it ! Do i need to keep working on LIbgdx or can i switch back and redevelop entierly my stuff on LWJGL ?
And last question, is there anyway to use the 1.0.0 of LIbgdx without using their Gradle system … ?
Thanks everyone