Package com.bomber7.core.model.square
Class Square
java.lang.Object
com.bomber7.core.model.texture.ElementTexture
com.bomber7.core.model.square.Square
Represents a square in the game, which can be a wall, a bomb, or any other future map element.
-
Field Summary
Fields inherited from class com.bomber7.core.model.texture.ElementTexture
FLIP_D, FLIP_H, FLIP_V, ID_MASK, NO_ROTATION, ROTATION_180, ROTATION_90, ROTATION_MINUS_90
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Square with the specified texture file path and texture ID.Constructs a new Square with the specified sprite file path and texture ID.Square
(String textureName, MapElement mapElement) Constructs a new Square with the specified texture file path and map element.Square
(String textureName, MapElement mapElement, boolean verticalFlip, boolean horizontalFlip, boolean diagonalFlip) Constructs a new Square with the specified texture file path and map element. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the map element associated with this square.Returns the map element associated with this square.boolean
Checks if this square has an associated map element.boolean
Checks if this square is walkable.void
setMapElement
(MapElement mapElement) Sets the map element associated with this square.toString()
Methods inherited from class com.bomber7.core.model.texture.ElementTexture
computeRotation, getTextureName, isDiagonalFlip, isHorizontalFlip, isVerticalFlip, setTextureName
-
Constructor Details
-
Square
Constructs a new Square with the specified texture file path and texture ID.- Parameters:
textureName
- the texture name for this square- Throws:
IllegalArgumentException
- if the sprite file path is null or empty
-
Square
public Square(String textureName, boolean verticalFlip, boolean horizontalFlip, boolean diagonalFlip) Constructs a new Square with the specified sprite file path and texture ID.- Parameters:
textureName
- the texture name for this squareverticalFlip
- whether to flip the texture verticallyhorizontalFlip
- whether to flip the texture horizontallydiagonalFlip
- whether to flip the texture diagonally- Throws:
IllegalArgumentException
- if the sprite file path is null or empty
-
Square
Constructs a new Square with the specified texture file path and map element.- Parameters:
textureName
- the texture name for this squaremapElement
- the map element associated with this square
-
Square
public Square(String textureName, MapElement mapElement, boolean verticalFlip, boolean horizontalFlip, boolean diagonalFlip) Constructs a new Square with the specified texture file path and map element.- Parameters:
textureName
- the texture name for this squaremapElement
- the map element associated with this squareverticalFlip
- whether to flip the texture verticallyhorizontalFlip
- whether to flip the texture horizontallydiagonalFlip
- whether to flip the texture diagonally
-
-
Method Details
-
hasMapElement
public boolean hasMapElement()Checks if this square has an associated map element.- Returns:
- true if there is a map element, false otherwise
-
setMapElement
Sets the map element associated with this square.- Parameters:
mapElement
- the map element to associate with this square
-
clearMapElement
public void clearMapElement()Clears the map element associated with this square. This method sets the map element to null. -
getMapElement
Returns the map element associated with this square.- Returns:
- the map element, or null if there is no associated map element
-
isWalkable
public boolean isWalkable()Checks if this square is walkable. A square is considered walkable if it does not have an associated map element.- Returns:
- false if there is a wall or a bomb, true otherwise
-
toString
-