- 1. Getting Started with OdyC
- 2. Naming Your Game
- 3. The Hero
- 4. How to Draw?
- 5. The Map
- 6. Dialogues
- 7. Sound in the Game
- 8. Advanced Template Parameters
- 9. Camera Control
- 10. Integrating Events
- 11. Event Target Manipulation
- 12. Dynamic Hero Modification
- 13. Modifying a Cell
- 14. Global Model Modification
- 15. Orchestration of Dialogues, Sounds, and Endings
- 16. Dynamically Loading Maps
The createGame
function, which we’ve been using since the beginning of this tutorial, provides access to the game’s context. This context allows you to dynamically modify the game, whether within event functions or outside the main game logic.
Modifying the Hero
To interact with and modify the player’s properties, you can act directly on the player
object accessible through the game’s context:
Interaction Through Events
The onEnter
, onCollide
, and onLeave
events offer a unique opportunity to modify the player’s state based on their interaction with the environment.
Usage Example
Imagine you want to change the player’s color when they pass through a specific area to indicate a change in state, such as a power-up or a temporary effect:
This method allows for the creation of dynamic interactions and visual effects that enrich the gaming experience and encourage exploration. Experiment with different properties and events to discover new ways to engage players in your game world.
Loading editor...
const game = createGame({ templates: { X: { sprite: 0, solid: false, onEnter: function(){ // When the player enters the specified area }, onLeave: function(){ // When the player leaves the specified area }, }, }, map: ` ........ ........ ........ ........ XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX ` })