-
Notifications
You must be signed in to change notification settings - Fork 2
Object Interaction
Entities that will have the ability to be interacted with by the player if they implement the InteractionComponent, allowing the player to trigger a specified event upon 'interacting' with it via the keyboard input 'E'. The component will also include optional functionality in order to allow it to trigger an event simply when the player is in contact with it, such as changing the sprite to display a yellow outline, or display an input prompt or tutorial (See examples below). The yellow outline indicates the user that the object is interactable.
-
PhysicsContactListener: This listens for all collisions/contact that occur between fixtures and calls functions at the start, end, during and post contact. -
PlayerObjectInteractions: This component is implemented by the Player entity and stores an ArrayList of entities that possess theInteractableComponentthat the Player is currently in contact with. -
InteractableComponent: Component which allows a entity to be interacted with.
-
Game Physics notice Player Collisions:
PhysicsContactListenerlistens for all physics collisions that occur, then retrieves the entities attached toFixturesparticipating in the collision. At game initiation, atargetFixturebelonging to the Player entity is parsed into thePhysicsContactListener. In all proceeding collisions, participating entities are compared totargetFixtureto detect Player Collisions. -
Collision is communicated to Player: On collision start, if the
targetFixtureis a participant,PhysicsContactListenerretrieves thetargetEntitycomponentPlayerObjectInteractionsand sends the non-player entity participating in the collision to this component. -
Player knows what object entities it can interact with: The
PlayerObjectInteractionscomponent checks that the entity sent implements theInteractableComponentand then appends the entity to a list which describes what objects the Player entity is touching at that moment. -
End of collision clean up: When the collision ends between the Player entity and the interactable object,
PhysicsContactListenerlets the PlayersPlayerObjectInteractionscomponent know, so that the interactable object can be removed from the list of objects [that the Player entity is touching].
-
Keyboard Input and Interaction Checking: When 'E' is detected as keyboard input, a empty event is called within the player entity class. The interactable objects that are present in
PlayerObjectInteractiondetect this through implemented listeners. -
Interaction Triggered: The triggered entities
InteractableComponentis accessed and a interaction event is triggered via theEventHandler. -
Interaction: The listener in the
InteractableComponentThe state of the entity, game state, or the Player entity is modified.
Each interactable component has a listener that triggers the entities trigger event. The action triggered by each trigger event is dependant on the object that the player interacts with.
-
Interactable Objects: For a object to be interactable it must implement the
InteractableComponent -
Interaction Entities: For a entity to interact with interactable objects, it must implement
PlayerObjectInteractions
| Latent Door Texture | Active Door Texture |
|---|---|
![]() |
![]() |
Current progress: For the moment, only a bed entity is being spawned. The door entity will trigger a level change. However, as no new level was created in sprint 1, the door interaction was not implimented.
| Latent Bed Texture | Active Bed Texture |
|---|---|
![]() |
![]() |
| Latent TV Texture | Switched off TV |
|---|---|
![]() |
![]() |

Entities and Components
Interaction System
Unit Testing
Input Handling
UI
Game Screens and Areas
Map Generation
Basic Interactable Objects Design




