Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelBarbosatec committed Apr 26, 2024
1 parent 274827e commit 8af65f3
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 45 deletions.
6 changes: 4 additions & 2 deletions v3.0/doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Now you can run to see your map:
directional: JoystickDirectional(),
), // required
map: WorldMapByTiled(
TiledReader.asset('tile/map.json')
WorldMapReader.fromAsset('tile/map.json')
),
);
}
Expand Down Expand Up @@ -113,7 +113,9 @@ Now you just need add your player in the game:
joystick: Joystick(
directional: JoystickDirectional(),
),
map: WorldMapByTiled('tile/map.json'),
map: WorldMapByTiled(
WorldMapReader.fromAsset('tile/map.json')
),
player: Knight(Vector2(40,40))
);
}
Expand Down
68 changes: 37 additions & 31 deletions v3.0/doc/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@ It is a matrix of small tiles that toghether assembles the map as seen below:
We currently recommend creating the map using [Tiled](https://www.mapeditor.org/). For that we use `WorldMapByTiled` in `BonfireWidget` in the `map` parameter:

```dart
WorldMapByTiled(TiledReader.asset('tile/map.json'), forceTileSize: Size(32,32))
WorldMapByTiled(WorldMapReader.fromAsset('tile/map.json'))
```

The first parameter (`tile/map.json`) is the path of the `.json` file exported by Tiled.

> IMPORTANT: Bonfire only supports .json files.
The second parameter (`Size(32,32)`) is optional and determines the size of each Tile on the map (squares). If not set it takes the default size defined by your TileSet.

You can load a map from url. Just pass the url in path. Example:

```dart
WorldMapByTiled(
TiledReader.network( Uri.parse('https://raw.githubusercontent.com/RafaelBarbosatec/rafaelbarbosatec.github.io/master/tiled/my_map.json')),
forceTileSize: Size(32,32),
WorldMapReader.fromNetwork(
Uri.parse('https://raw.githubusercontent.com/RafaelBarbosatec/rafaelbarbosatec.github.io/master/tiled/my_map.json')
),
)
```

Expand All @@ -36,8 +35,7 @@ You can add objects like [Decorations](doc/decoration?id=decoration) and [Enemie
```dart
return BonfireWidget(
map: WorldMapByTiled(
TiledReader.asset('tiled/map.json'),
forceTileSize: Size(32,32),
WorldMapReader.fromAsset('tiled/map.json'),
objectsBuilder: {
'orc': (TiledObjectProperties properties) => Orc(properties.position),
},
Expand Down Expand Up @@ -85,18 +83,22 @@ To use this resource is very easy:
return BonfireWidget(
map: MatrixMapGenerator.generate(
axisInverted: true,
matrix: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
layers: [
MatrixLayer(
matrix: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
)
],
builder: (ItemMatrixProperties prop){
Expand Down Expand Up @@ -220,18 +222,22 @@ After that you pass the 'build' method of the `terrainBuilder` to `builder`:
return BonfireWidget(
map: MatrixMapGenerator.generate(
axisInverted: true, // This is `true` to create the map same as seen in the matrix. Because the normal axis is `matrix[x][y]`, When `axisInverted` is `true` it's turn `matrix[y][x]`
matrix: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
layers: [
MatrixLayer(
matrix: [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 2, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
],
)
],
builder: terrainBuilder.build,
),
Expand Down
21 changes: 11 additions & 10 deletions v3.0/doc/mixins.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,23 @@ Adds these methods in your component:
void addLife(double life)
void updateLife(double life,{bool verifyDieOrRevive = true})
void removeLife(double life)
/// This method is used to check if this component can receive damage from any attacker.
@override
bool checkCanReceiveDamage(
AttackFromEnum attacker,
double damage,
dynamic from,
)
/// You can listen if this component receive attack
// If returns true, this component received damage.
@override
void receiveDamage(double damage, dynamic from)
bool receiveDamage(
AttackOriginEnum attacker,
double damage,
dynamic identify,
)
/// If your life stay minor than 0 this method is called
@override
void die()
void onDie()
/// If you dead and revive
@override
void onRevive()
```

## Vision
Expand Down
4 changes: 2 additions & 2 deletions v3.0/doc/tiled_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ For maps built with Tiled we must use the Widget `BonfireWidget` (example [here]
directional: JoystickDirectional()
),
map: WorldMapByTiled(
TiledReader.asset('tiled/map.json'),
WorldMapReader.fromAsset('tiled/map.json'),
forceTileSize: DungeonMap.tileSize, // if you want to force the size of the Tile to be larger or smaller than the original
objectsBuilder: {
'goblin': (TiledObjectProperties properties) => Goblin(properties.position),
Expand Down Expand Up @@ -73,7 +73,7 @@ You can storage your map files in a server and load. Just load using `TiledReade
directional: JoystickDirectional()
),
map: WorldMapByTiled(
TiledReader.network(
WorldMapReader.fromNetwork(
Uri.parse('http://rafaelbarbosatec.github.io/tiled/my_map.json'),
// cacheProvider: TiledMemoryCacheProvider()
),
Expand Down

0 comments on commit 8af65f3

Please sign in to comment.