Class Room
java.lang.Object
rooms.Room
- Direct Known Subclasses:
CombatRoom,NormalRoom,StoreRoom,TreasureRoom
Abstract base class for all types of rooms in the game.
Handles entities such as enemies, bullets, items, lasers, and the player. Provides update and render methods for the room and its entities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a door to the room.voidAdds an enemy to the room and to the characters list.protected voiddrawFog(javafx.scene.canvas.GraphicsContext gc, javafx.scene.paint.Color edgeColor, double strength) Draws fog/smoke effect over the room.getDoorAtPlayer(javafx.geometry.Rectangle2D playerHitbox) Checks if the player intersects the door.javafx.scene.image.ImagedoublegetItems()doublegetWidth()booleanisActive()voidrender(javafx.scene.canvas.GraphicsContext gc) Base render method for the room.voidrenderEntities(javafx.scene.canvas.GraphicsContext gc) Renders bullets, enemies, items, and lasers in the roomvoidsetActive(boolean active) voidSpawns a bullet in the room.voidspawnItems(Item i) Schedules an item to be added to the room.voidspawnLaser(Laser l) Spawns a laser in the room.voidupdate(double dt) Updates the room and its entities.voidupdateEntities(double dt) Updates all entities in the room: enemies, bullets, items, lasers.
-
Field Details
-
FLOOR_SPRITE
private static javafx.scene.image.Image FLOOR_SPRITEShared floor sprite for all rooms -
active
public boolean activeWhether this room is currently active -
player
-
x
protected double x -
y
protected double y -
width
protected double width -
height
protected double height -
topDoor
-
enemies
-
bullets
-
items
-
pendingItems
-
characters
-
lasers
-
-
Constructor Details
-
Room
Constructs a room with specified size and player reference.- Parameters:
x- top-left x-coordinatey- top-left y-coordinatewidth- width of the roomheight- height of the roomplayer- the player object inside the room
-
-
Method Details
-
addEnemy
Adds an enemy to the room and to the characters list.- Parameters:
e- enemy to add
-
spawnBullet
-
spawnItems
Schedules an item to be added to the room.- Parameters:
i- item to spawn
-
spawnLaser
-
getWidth
public double getWidth()- Returns:
- width of the room
-
getHeight
public double getHeight()- Returns:
- height of the room
-
getEnemies
-
getBullets
-
getItems
-
getLasers
-
getCharacters
-
getFloorSprite
public javafx.scene.image.Image getFloorSprite()- Returns:
- shared floor sprite
-
addDoor
-
getDoorAtPlayer
Checks if the player intersects the door.- Parameters:
playerHitbox- the player's hitbox- Returns:
- the door if intersecting, otherwise null
-
updateEntities
public void updateEntities(double dt) Updates all entities in the room: enemies, bullets, items, lasers.- Parameters:
dt- delta time in seconds
-
renderEntities
public void renderEntities(javafx.scene.canvas.GraphicsContext gc) Renders bullets, enemies, items, and lasers in the room -
setActive
public void setActive(boolean active) -
isActive
public boolean isActive() -
drawFog
protected void drawFog(javafx.scene.canvas.GraphicsContext gc, javafx.scene.paint.Color edgeColor, double strength) Draws fog/smoke effect over the room.- Parameters:
gc- GraphicsContextedgeColor- color of the outer edgestrength- opacity of the fog
-
render
public void render(javafx.scene.canvas.GraphicsContext gc) Base render method for the room.- Parameters:
gc- GraphicsContext
-
update
public void update(double dt) Updates the room and its entities.- Parameters:
dt- delta time in seconds
-