I am trying to recreate a game like Splix.io using FXGL, I have implemented the logic of the game for one player and it works. And for my game window I am using a 800*800 window. My problem is my game should be "unbounded" which means that the player should be able to move till infinity if it desires it and I have been trying different stuff to make this happen but none of them work.
As you know Splix.io has a gird like board so to create this grid I created Light Gray cells of 20 pixels like this:
@Spawns("cell")
public Entity newCell(SpawnData data) {
return FXGL.entityBuilder(data)
.view(new Rectangle(BLOCK_SIZE,BLOCK_SIZE, Color.LIGHTGRAY))
.with(new CellComponent())
.build();
}
@Spawns("player")
public Entity newPlayer(SpawnData data) {
return FXGL.entityBuilder(data)
.view("steve.png")
.zIndex(100)
.build();
}
and this is how I initialize the game board at the start:
cells = new Entity[40][40];
player = spawn("player", 400, 400);
for (int y = 0; y < 40; y++) {
for (int x = 0; x < 40; x++) {
cells[x][y] = spawn("cell", x * BLOCK_SIZE, y * BLOCK_SIZE);
}
}
Can someone tell me how I can make this fixed size game unbounded? One idea that I had was to check if the player comes close to any side of the window and if they get close I make the game window bigger and move the board but I don't know if this is the right way or not and even if it is, I don't know how to properly implement it.