Class GameField

java.lang.Object
de.tum.cit.fop.maze.Parser.GameField

public class GameField extends Object
Represents the game field grid containing tiles and game objects.
  • Constructor Details

    • GameField

      public GameField(int width, int height)
  • Method Details

    • getTile

      public TileType getTile(int x, int y)
      Gets the tile type at specified coordinates.
      Parameters:
      x - X coordinate
      y - Y coordinate
      Returns:
      The tile type, or WALL if out of bounds
    • getGameObjects

      public List<GameObject> getGameObjects()
      Gets all game objects in the field.
      Returns:
      List of game objects
    • getPlayerStartPos

      public com.badlogic.gdx.math.Vector2 getPlayerStartPos()
      Gets the player's starting position.
      Returns:
      Player start position vector
    • setPlayerStartPos

      public void setPlayerStartPos(com.badlogic.gdx.math.Vector2 pos)
      Sets the player's starting position.
      Parameters:
      pos - New start position
    • getWidth

      public int getWidth()
      Gets the field width.
      Returns:
      Width in tiles
    • getRequiredKeys

      public int getRequiredKeys()
      Gets the number of keys required to open the exit.
      Returns:
      Number of keys in the field
    • getHeight

      public int getHeight()
      Gets the field height.
      Returns:
      Height in tiles
    • getObjectsByType

      public <T extends GameObject> List<T> getObjectsByType(Class<T> type)
      Gets all game objects of a specific type.
      Type Parameters:
      T - Type parameter extending GameObject
      Parameters:
      type - The class type to filter by
      Returns:
      List of objects matching the type
    • getTileTypeCoords

      public com.badlogic.gdx.math.Vector2 getTileTypeCoords(GameField newMap, TileType TYPE)
    • setTile

      public void setTile(int x, int y, TileType tile)
      Sets a tile at specified coordinates.
      Parameters:
      x - X coordinate
      y - Y coordinate
      tile - Tile type to set
    • addGameObject

      public void addGameObject(GameObject obj)
      Adds a game object to the field.
      Parameters:
      obj - The game object to add
    • isInsideWall

      public boolean isInsideWall(float x, float y, com.badlogic.gdx.math.Vector2 size)
      Checks if a position overlaps with any solid tile.
      Parameters:
      x - X position
      y - Y position
      size - Object size for collision checking
      Returns:
      True if inside a wall or solid tile