Outils pour utilisateurs

Outils du site


en:yaml:tutoriel-2d

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
en:yaml:tutoriel-2d [2026/10/19 01:29] – Wiki 4.17 : corrections apres audit des exemples et traductions cyrilfiestaen:yaml:tutoriel-2d [2026/10/19 04:19] (Version actuelle) – Retrait du tutoriel 2D et de ses liens, a la demande de l'auteur cyrilfiesta
Ligne 1: Ligne 1:
-**Language / Langue :** [[fr:yaml:tutoriel-2d|FR]] | **EN** 
- 
-====== A small 2D board ====== 
- 
-A board can fit inside one room: numbers describe the terrain, a list holds images, and actions change coordinates. JDR-Bot remains a scenario engine; movement and collision rules are written by the author. 
- 
-===== A cell and its image ===== 
- 
-On a 7-column board, a cell number is ''y * 7 + x''. Coordinates start at 0, increasing rightwards and downwards. Cell (1, 1) is therefore number 8. 
- 
-<code yaml> 
-title: The garden 
-vars: 
-  x: 1 
-  y: 1 
-  cell: 0 
-lists: 
-  terrain: [ 
-    0, 0, 0, 0, 0, 0, 0, 
-    0, 1, 1, 1, 1, 1, 0, 
-    0, 1, 1, 0, 1, 1, 0, 
-    0, 1, 1, 0, 1, 1, 0, 
-    0, 1, 1, 0, 1, 1, 0, 
-    0, 1, 1, 1, 1, 1, 0, 
-    0, 0, 0, 0, 0, 0, 0 
-  ] 
-  grid: [] 
-  tiles: [ 
-    /images/public/mini-doom/tileset.svg:4x4:0:0, 
-    /images/public/mini-doom/tileset.svg:4x4:1:0, 
-    /images/public/mini-doom/tileset.svg:4x4:3:0 
-  ] 
-</code> 
- 
-The terrain holds 49 values in one list: 0 means wall and 1 means floor. Images come from the Mini Doom tileset supplied with the Web/Desktop project. On another host, provide that image too or change its address. 
- 
-===== Rebuild the display ===== 
- 
-Add this automatic event and its room after the declarations: 
- 
-<code yaml> 
-global_events: 
-  - id: draw_board 
-    state: 'ON' 
-    do: 
-      - do: 
-          - list: grid 
-            keep: 0 
-          - for_each: floor 
-            in: terrain 
-            do: 
-              - {list: grid, append: 't_tiles[v_floor_v]_t'} 
-          - cell = v_y_v 
-          - cell * 7 
-          - cell + v_x_v 
-          - text_var: grid[v_cell_v] 
-            value: t_tiles[2]_t 
-rooms: 
-  - id: garden 
-    auto_refresh: true 
-    text: '[[grid:7:grid]]' 
-</code> 
- 
-Combine the two blocks in one YAML file to view the board with Test. The text uses ''%%[[grid:7:grid]]%%''; the same marker works in a HUD. Draw the terrain first and the player afterwards. This first example only displays the board; the rules come next. 
- 
-===== Add rules ===== 
- 
-  - **Movement**: calculate a destination, check coordinates, then read the terrain. Move only if the cell is free. 
-  - **Key**: a collection ''key: {x: 1, y: 5, taken: 0}'' stores its position and state. Compare coordinates after moving. 
-  - **Exit**: check position and ''key.taken'' before declaring victory. 
-  - **Random placement**: collect reachable floor cells in a list, then ''choose: random'' for one key. Use ''draw: random'' for several objects without reusing the same cell. 
- 
-Choose positions during setup, not after every move. The scenario must ensure the selected cells are reachable: the grid does not find paths. 
- 
-===== With the editor ===== 
- 
-Create numbers, lists and collections under **Globals > Variables**. Add loops and operations in an event's ''do:'', buttons in room actions, then the grid marker in a HUD. The **Expert** profile exposes all these fields. 
- 
-Test walls, the key, the exit and Restart. **Test data** lets you inspect coordinates and lists in a separate window without resizing the game. 
- 
-If you have the JDR-Bot sources, two French tutorials at the project root build **La clé du jardin** in five steps: ''TUTORIEL-2D-YAML.md'' and ''TUTORIEL-2D-EDITEUR.md''. Matching YAML and ''.jdrproj'' files are in ''dev/exemples/tutoriel-2d/''. These paths refer to project files, not wiki pages. Snake and Mini Doom provide larger examples. 
- 
-See [[en:yaml:listes-boucles|Lists and loops]], [[en:yaml:tiles-tilemaps|Tiles and grids]] and [[en:yaml:raccourcis|Shortcuts]]. 
  
en/yaml/tutoriel-2d.1792366191.txt.gz · Dernière modification : de cyrilfiesta