- 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
In the provided example, we want the player to be teleported to room2
when they step on the black square.
The loadMap
method opens the door to a variety of applications such as progressing through levels, activating teleporters, discovering secret doors, and more.
Basic Usage
To load a new map, simply invoke the loadMap
method on the game
object, passing the desired map as a parameter:
Player Positioning
The loadMap
function also offers the ability to reposition the player to a new location on the loaded map, thus providing greater flexibility in scene and transition management:
Warning
When ending the game using the
end
parameter of a template or thegame.end
method, the game will be reset to its state following the last call togame.loadMap
. Therefore, it’s important to plan the use of this method within your game flow to ensure a consistent user experience.
Loading editor...
const room1 = ` xxxxxxxx x.....Ox x......x x......x x......x x......x x......x xxxxxxxx ` const room2 = ` xxxxxxxx x....x.x x....xHx x......x x......x x......x x......x xxxxxxxx ` const game = createGame({ player: { sprite: 4, position: [1, 1], }, templates: { x: { sprite: 2, }, H: { sprite: ` .2.2.2.2 .2.2.2.2 .2.2.2.2 .2.2.2.2 .2.2.2.2 .2.2.2.2 .2.2.2.2 .2.2.2.2 `, }, O: { sprite: 0, solid: false, onEnter: function () { }, }, }, map: room1, })