Class Chunk

java.lang.Object
org.collebol.game.world.Chunk

public abstract class Chunk extends Object
The Chunk class represents a segment of the game world, containing tiles ad entities. It is used to manage and organize game objects within a specific area, defined by its size and position.

Each chunk holds a collection of tiles and entities, allowing for efficient rendering and updating the game world.

Usage:

     MyChunk chunk = new MyChunk(chunkSize, chunkX, chunkY);
     chunk.addTile(tile);
 
Since:
1.0-dev
Author:
ColleBol - contact@collebol.org
  • Constructor Details

    • Chunk

      public Chunk(int chunkSize, int x, int y)
      Chunk constructor.
      Parameters:
      chunkSize - the size of the chunk. Example: 16 (16x16)
      x - the x-coordinate of the chunk.
      y - the y-coordinate of the chunk.
  • Method Details

    • getChunkSize

      public int getChunkSize()
    • setChunkSize

      public void setChunkSize(int chunkSize)
    • getX

      public int getX()
    • setX

      public void setX(int x)
    • getY

      public int getY()
    • setY

      public void setY(int y)
    • addTile

      public void addTile(GameObject tile)
      Adds a tile to the chunk.
      Parameters:
      tile - tile to be added.
      Throws:
      RuntimeException - if the tile's GameLocation is null.
    • addEntity

      public void addEntity(GameObject entity)
    • getTiles

      public List<GameObject> getTiles()
      Returns:
      a list of all tiles in the Chunk.
    • getTilesAsMap

      public Map<Integer,List<GameObject>> getTilesAsMap()
      Returns:
      a map of tiles grouped by their texture id.
    • getEntities

      public List<GameObject> getEntities()