0

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.

  • See also [_Game Development Stack Exchange_](https://gamedev.stackexchange.com), which may offer insight on arbitrarily large models. – trashgod Jul 22 '23 at 18:30
  • You could use a [tile engine](https://www.javacodegeeks.com/2013/01/writing-a-tile-engine-in-javafx.html), (careful the link has a lot of advertising spam I cannot control but is the only available link because the original blog post no longer exists). The link outlines the concept and provides snippets of example code for an implementation, but not a complete implementation. FXGL may have a similar concept built-in, so I suggest investigating that before trying to build your own (non-trivial) or searching for a [3rd party solution](https://github.com/Kogs/JavaFXTileMap). – jewelsea Jul 22 '23 at 19:31
  • 1
    I did a quick search on FXGL and tile map, and [the first link that turned up was [Building Levels Using Tiled Map Editor (FXGL 11)](https://github.com/AlmasB/FXGL/wiki/Building-Levels-Using-Tiled-Map-Editor-(FXGL-11)) – jewelsea Jul 22 '23 at 19:33

0 Answers0