tile
Module(s): vncanvas-base, vncanvas-cmds
Description: Create old-school dungeon crawling navigation... or maze... or forest... or mansion...
- Should be used with a cform displaying navigation buttons.
- Uses three reserved user variables:
"_nav_loc" for the current location,
"_nav_dir" for the facing direction,
and "_nav_move" for the player movement.
tile, {param} |
Define a tile for navigation. Parameters are given as {param:value, param:value, ...} |
Parameter | Attributes and Description |
---|---|
id:"tile_id"
|
The id of the tile.
|
wall:[array_of_wall_images]
|
Defines the four wall images of the
tile, in north, east, south and west (or clockwise) order.
Note that wall does not necessarily mean a solid wall, but simply an image/backdrop that is displayed when the player is facing said direction. |
link:[array_of_labels]
|
This determines where to jump to
when the player moves in the given direction.
The order in the array corresponds to the wall order, i.e. north, east, south, and west order. |
map:[x_position, y_position]
|
Optional
When automap is used, this defines the
position of the current tile.
|
First, declare a cform navigation controller using buttons. Up arrow moves the player forward.
Down arrow moves the player back. Left and Right arrows turns the player counterclockwise
and clockwise, respectively.
chapter = [ ... cform, [ "nav_tile", false, button, {name:"nav_up", x:540, y:240, base:"arrows-up.png", link:[set, {_nav_move:"forward"}], showText:false }, button, {name:"nav_down", x:540, y:380, base:"arrows-down.png", link:[set, {_nav_move:"back"}], showText:false }, button, {name:"nav_left", x:480, y:300, base:"arrows-left.png", link:[set, {_nav_move:"left"}], showText:false }, button, {name:"nav_left", x:620, y:300, base:"arrows-right.png", link:[set, {_nav_move:"right"}], showText:false }, ], ... ];
This creates a cform with four buttons. Clicking on the button sets the "_nav_move"
variable as to the type of player movement.
As the cform is a non-modal cform, it just stays on the screen and responds to user click anytime.
Next define the tileset of the dungeon... or maze... or mansion... This also gives a visual as to the walls needed, which tile is next to which tile, etc.
As the cform is a non-modal cform, it just stays on the screen and responds to user click anytime.
Next define the tileset of the dungeon... or maze... or mansion... This also gives a visual as to the walls needed, which tile is next to which tile, etc.
Finally, create a definition for each tile. Below is a definition of tile T1.
chapter = [ ... label, "T1", tile, {id:"T1", wall:["wall1n.jpg", "wall1e.jpg", "wall1s.jpg", "wall1w.jpg"], link:["T1", "T3", "T1", "T1"] }, /* do some stuff here, hide/show cform if necessary */ wait, 0, /* see note below on flow control */ jump, "T1", ... ];
The walls are declared as in the diagram. The links are followed when the forward
and back buttons are clicked. Note that a link to itself, i.e. T1, causes it to
jump back to itself, since player can not move in that direction anyway.
Note also that "tile" is merely a definition and does not pause/stop script execution. So make sure to use flow controls or elements that pauses execution, such as "text". In the above construct, without the "wait" statement, the loop will execute continuously when the navigation buttons are not pressed or the player stays at T1.
For a complete example, see Navigation Demo.
Note also that "tile" is merely a definition and does not pause/stop script execution. So make sure to use flow controls or elements that pauses execution, such as "text". In the above construct, without the "wait" statement, the loop will execute continuously when the navigation buttons are not pressed or the player stays at T1.
For a complete example, see Navigation Demo.