Bastien Sevajol 3 years ago
parent
commit
d0ffd058b7

+ 1 - 0
CREDITS View File

@@ -0,0 +1 @@
1
+Palm tree: Warlock's Gauntlet artists - rAum, jackFlower, DrZoliparia, Neil2D (https://opengameart.org/content/top-down-foliage-collection)

+ 95 - 2
resources/map1.tmx View File

@@ -1,10 +1,15 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2
-<map version="1.5" tiledversion="1.6.0" orientation="orthogonal" renderorder="right-down" width="112" height="64" tilewidth="5" tileheight="5" infinite="0" nextlayerid="3" nextobjectid="1">
2
+<map version="1.5" tiledversion="1.6.0" orientation="orthogonal" renderorder="right-down" width="112" height="64" tilewidth="5" tileheight="5" infinite="0" nextlayerid="7" nextobjectid="8">
3 3
  <tileset firstgid="1" source="terrain.tsx"/>
4
+ <tileset firstgid="2001" source="trees_64x64.tsx"/>
5
+ <tileset firstgid="2010" source="trees_32x32.tsx"/>
4 6
  <imagelayer id="2" name="background">
5 7
   <image source="map1bg.png" width="560" height="320"/>
6 8
  </imagelayer>
7
- <layer id="1" name="terrain" width="112" height="64">
9
+ <imagelayer id="6" name="roofs">
10
+  <image source="roofs.png" width="560" height="320"/>
11
+ </imagelayer>
12
+ <layer id="1" name="terrain" width="112" height="64" visible="0">
8 13
   <data encoding="csv">
9 14
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,4,4,4,5,4,4,5,4,4,4,
10 15
 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,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,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,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,0,
144
+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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0,
145
+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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0
146
+</data>
147
+ </layer>
148
+ <objectgroup id="4" name="interior">
149
+  <object id="2" x="29" y="112">
150
+   <polygon points="0,0 0,56 29.25,56 28.75,49.25 63.75,50 64,-5.5 37.5,-4.5 37.75,-0.25"/>
151
+  </object>
152
+  <object id="3" x="115.5" y="247.5">
153
+   <polygon points="0,0 15.25,71.75 181.75,40.75 159.25,-27.25"/>
154
+  </object>
155
+  <object id="4" x="230" y="223.5">
156
+   <polygon points="0,0 55,-14 50,-48.75 119.25,-56.5 139.25,54.5 12,80.25"/>
157
+  </object>
158
+  <object id="5" x="363.25" y="177">
159
+   <polygon points="0,0 67.75,-10.75 71.75,51.75 6.5,55.75"/>
160
+  </object>
161
+  <object id="6" x="435.75" y="171">
162
+   <polygon points="0,0 -0.5,93 75.25,92.75 73.75,-0.75"/>
163
+  </object>
164
+  <object id="7" x="275" y="9.75">
165
+   <polygon points="0,0 204,-6 202.75,82 -0.75,87"/>
166
+  </object>
167
+ </objectgroup>
75 168
 </map>

BIN
resources/roofs.png View File


BIN
resources/trees_32x32.png View File


+ 4 - 0
resources/trees_32x32.tsx View File

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<tileset version="1.5" tiledversion="1.6.0" name="trees_32x32" tilewidth="32" tileheight="32" tilecount="100" columns="10">
3
+ <image source="trees_32x32.png" width="320" height="320"/>
4
+</tileset>

BIN
resources/trees_64x64.png View File


+ 4 - 0
resources/trees_64x64.tsx View File

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<tileset version="1.5" tiledversion="1.6.0" name="trees_64x64" tilewidth="64" tileheight="64" tilecount="9" columns="3">
3
+ <image source="trees_64x64.png" width="192" height="192"/>
4
+</tileset>

+ 61 - 0
src/map/decor.rs View File

@@ -0,0 +1,61 @@
1
+use crate::map::util::extract_image_from_tileset;
2
+use ggez::graphics;
3
+use std::collections::HashMap;
4
+use std::path::Path;
5
+use tiled::{Image as TiledImage, Layer, Tileset};
6
+
7
+pub struct DecorTile {
8
+    pub tileset_i: usize, // Used to rely tileset/sprite_batch in Decor
9
+    pub tile_width: u32,
10
+    pub tile_height: u32,
11
+    pub relative_tile_width: f32,
12
+    pub relative_tile_height: f32,
13
+    pub tile_x: u32,
14
+    pub tile_y: u32,
15
+}
16
+
17
+impl DecorTile {
18
+    pub fn new(
19
+        tileset_i: usize, // Used to rely tileset/sprite_batch in Decor
20
+        tile_width: u32,
21
+        tile_height: u32,
22
+        relative_tile_width: f32,
23
+        relative_tile_height: f32,
24
+        tile_x: u32,
25
+        tile_y: u32,
26
+    ) -> Self {
27
+        Self {
28
+            tileset_i,
29
+            tile_width,
30
+            tile_height,
31
+            relative_tile_width,
32
+            relative_tile_height,
33
+            tile_x,
34
+            tile_y,
35
+        }
36
+    }
37
+}
38
+
39
+pub struct Decor {
40
+    pub layer: Layer,
41
+    pub tilesets: Vec<Tileset>,
42
+    pub images: Vec<TiledImage>,
43
+    // FIXME (u32, u32) -> GridPoint
44
+    pub tiles: HashMap<(u32, u32), DecorTile>,
45
+}
46
+
47
+impl Decor {
48
+    pub fn new(
49
+        layer: Layer,
50
+        tilesets: Vec<Tileset>,
51
+        images: Vec<TiledImage>,
52
+        tiles: HashMap<(u32, u32), DecorTile>,
53
+    ) -> Self {
54
+        Self {
55
+            layer,
56
+            tilesets,
57
+            images,
58
+            tiles,
59
+        }
60
+    }
61
+}

+ 88 - 118
src/map/mod.rs View File

@@ -1,75 +1,32 @@
1
-pub mod tile;
2
-
3
-use crate::map::tile::Tile;
4
-use ggez::GameError;
5
-use ggez::GameResult;
6 1
 use std::collections::HashMap;
7 2
 use std::fs::File;
8 3
 use std::io::BufReader;
9 4
 use std::path::Path;
5
+
6
+use ggez::GameError;
7
+use ggez::GameResult;
10 8
 use tiled::{
11
-    parse_with_path, Image as TiledImage, Layer, LayerData, Map as TiledMap, Orientation,
12
-    PropertyValue, Tileset,
9
+    parse_with_path, Image as TiledImage, Image, ImageLayer, Layer, LayerData, Map as TiledMap,
10
+    Orientation, PropertyValue, Tileset,
13 11
 };
14 12
 
15
-fn get_tile_from_terrain_tileset_with_id(
16
-    terrain_tileset: &Tileset,
17
-    id: u32,
18
-    terrain_image_width: u32,
19
-    terrain_image_height: u32,
20
-) -> GameResult<Tile> {
21
-    for tile in terrain_tileset.tiles.iter() {
22
-        if tile.id == id - terrain_tileset.first_gid {
23
-            let str_id = match tile.properties.get("ID") {
24
-                None => {
25
-                    return GameResult::Err(GameError::ResourceLoadError(format!(
26
-                        "Tile {} have no ID property",
27
-                        id
28
-                    )))
29
-                }
30
-                Some(property_value) => match property_value {
31
-                    PropertyValue::StringValue(str_id) => str_id.clone(),
32
-                    _ => {
33
-                        return GameResult::Err(GameError::ResourceLoadError(format!(
34
-                            "Tile {} must have String ID property value",
35
-                            id
36
-                        )))
37
-                    }
38
-                },
39
-            };
40
-
41
-            let tile_width = terrain_tileset.tile_width;
42
-            let tile_height = terrain_tileset.tile_height;
43
-            let relative_tile_width = tile_width as f32 / terrain_image_width as f32;
44
-            let relative_tile_height = tile_height as f32 / terrain_image_height as f32;
45
-            let len_by_width = terrain_image_width / tile_width;
46
-            let tile_y = tile.id / len_by_width;
47
-            let tile_x = tile.id - (tile_y * len_by_width);
48
-
49
-            return GameResult::Ok(Tile::from_str_id(
50
-                &str_id,
51
-                tile_width,
52
-                tile_height,
53
-                relative_tile_width,
54
-                relative_tile_height,
55
-                tile_x,
56
-                tile_y,
57
-            ));
58
-        }
59
-    }
13
+use crate::map::decor::{Decor, DecorTile};
14
+use crate::map::terrain::{Terrain, TerrainTile};
15
+use crate::map::util::{
16
+    extract_gids, extract_image_from_image_layer, extract_image_from_tileset, extract_layer,
17
+    extract_tileset, extract_tileset_images, extract_tilesets_containing_gids,
18
+    get_tileset_i_for_gid,
19
+};
60 20
 
61
-    return GameResult::Err(GameError::ResourceLoadError(format!(
62
-        "No tile with {} found",
63
-        id
64
-    )));
65
-}
21
+pub mod decor;
22
+pub mod terrain;
23
+pub mod util;
66 24
 
67 25
 pub struct Map {
68 26
     pub tiled_map: TiledMap,
69 27
     pub background_image: TiledImage,
70
-    pub terrain_image: TiledImage,
71
-    pub terrain_tileset: Tileset,
72
-    pub tiles: HashMap<(u32, u32), Tile>,
28
+    pub terrain: Terrain,
29
+    pub decor: Decor,
73 30
 }
74 31
 
75 32
 impl Map {
@@ -91,72 +48,30 @@ impl Map {
91 48
                 "Map must be orthogonal orientation".to_string(),
92 49
             ));
93 50
         }
94
-        // FIXME BS NOW: manage correctly error
95
-        let background_image = match &(tiled_map.image_layers.first().unwrap()).image.as_ref() {
96
-            None => {
97
-                return GameResult::Err(GameError::ResourceLoadError(
98
-                    "No image layer found in map ".to_string(),
99
-                ))
100
-            }
101
-            Some(image) => image.clone(),
102
-        };
103
-
104
-        let terrain_tileset: Tileset = match tiled_map
105
-            .tilesets
106
-            .clone()
107
-            .into_iter()
108
-            .filter(|t| t.name == "terrain")
109
-            .collect::<Vec<Tileset>>()
110
-            .first()
111
-        {
112
-            None => {
113
-                return GameResult::Err(GameError::ResourceLoadError(
114
-                    "No terrain tileset found in map ".to_string(),
115
-                ))
116
-            }
117
-            Some(tileset) => tileset.clone(),
118
-        };
119
-
120
-        let terrain_image = {
121
-            match terrain_tileset.images.first() {
122
-                None => {
123
-                    return GameResult::Err(GameError::ResourceLoadError(
124
-                        "No terrain image found in terrain tileset".to_string(),
125
-                    ))
126
-                }
127
-                Some(terrain_image) => terrain_image.clone(),
128
-            }
129
-        };
130 51
 
131
-        let terrain_layer: Layer = match tiled_map
132
-            .layers
133
-            .clone()
134
-            .into_iter()
135
-            .filter(|l| l.name == "terrain")
136
-            .collect::<Vec<Layer>>()
137
-            .first()
138
-        {
139
-            None => {
140
-                return GameResult::Err(GameError::ResourceLoadError(
141
-                    "No terrain layer found in map ".to_string(),
142
-                ))
143
-            }
144
-            Some(layer) => layer.clone(),
145
-        };
52
+        // Background and roofs
53
+        let background_image = extract_image_from_image_layer(&tiled_map, "background")?;
54
+        let roofs_image = extract_image_from_image_layer(&tiled_map, "roofs")?;
55
+        // let roofs_layer = ...
146 56
 
147
-        let mut tiles: HashMap<(u32, u32), Tile> = HashMap::new();
57
+        // Terrain
58
+        let terrain_tileset: Tileset = extract_tileset(&tiled_map, "terrain")?;
59
+        let terrain_layer: Layer = extract_layer(&tiled_map, "terrain")?;
60
+        let terrain_image = extract_image_from_tileset(&terrain_tileset)?;
148 61
 
149
-        match terrain_layer.tiles {
62
+        let mut terrain_tiles: HashMap<(u32, u32), TerrainTile> = HashMap::new();
63
+        match &terrain_layer.tiles {
150 64
             LayerData::Finite(layer_tiles) => {
151 65
                 for (x, tiles_row) in layer_tiles.iter().enumerate() {
152 66
                     for (y, layer_tile) in tiles_row.iter().enumerate() {
153
-                        let tile = get_tile_from_terrain_tileset_with_id(
67
+                        // FIXME BS NOW: et si gid = 0 ?
68
+                        let tile = terrain::get_tile_from_terrain_tileset_with_id(
154 69
                             &terrain_tileset,
155 70
                             layer_tile.gid,
156 71
                             terrain_image.width as u32,
157 72
                             terrain_image.height as u32,
158 73
                         )?;
159
-                        tiles.insert((y as u32, x as u32), tile);
74
+                        terrain_tiles.insert((y as u32, x as u32), tile);
160 75
                     }
161 76
                 }
162 77
             }
@@ -167,12 +82,67 @@ impl Map {
167 82
             }
168 83
         }
169 84
 
85
+        let terrain = Terrain::new(terrain_tileset, terrain_layer, terrain_image, terrain_tiles);
86
+
87
+        // Decor
88
+        let mut decor_tiles: HashMap<(u32, u32), DecorTile> = HashMap::new();
89
+        let decor_layer: Layer = extract_layer(&tiled_map, "decor")?;
90
+        let decor_tile_gids = extract_gids(&decor_layer)?;
91
+        let decor_tilesets: Vec<Tileset> =
92
+            extract_tilesets_containing_gids(&tiled_map, decor_tile_gids);
93
+        let decor_images: Vec<TiledImage> = extract_tileset_images(&decor_tilesets)?;
94
+
95
+        match &decor_layer.tiles {
96
+            LayerData::Finite(layer_tiles) => {
97
+                for (x, tiles_row) in layer_tiles.iter().enumerate() {
98
+                    for (y, layer_tile) in tiles_row.iter().enumerate() {
99
+                        if layer_tile.gid == 0 {
100
+                            continue;
101
+                        }
102
+
103
+                        let tileset_i = get_tileset_i_for_gid(layer_tile.gid, &decor_tilesets)
104
+                            .expect("gid must be find");
105
+                        let tileset = decor_tilesets
106
+                            .get(tileset_i)
107
+                            .expect("Decor tileset must be here");
108
+                        let image = decor_images.get(tileset_i).expect("Image must exist");
109
+
110
+                        let tiled_tile_id = layer_tile.gid - tileset.first_gid;
111
+                        let tile_width = tileset.tile_width;
112
+                        let tile_height = tileset.tile_height;
113
+                        let relative_tile_width = tile_width as f32 / image.width as f32;
114
+                        let relative_tile_height = tile_height as f32 / image.height as f32;
115
+                        let len_by_width = image.width as u32 / tile_width;
116
+                        let tile_y = tiled_tile_id / len_by_width;
117
+                        let tile_x = tiled_tile_id - (tile_y * len_by_width);
118
+
119
+                        let tile = DecorTile::new(
120
+                            tileset_i,
121
+                            tile_width,
122
+                            tile_height,
123
+                            relative_tile_width,
124
+                            relative_tile_height,
125
+                            tile_x,
126
+                            tile_y,
127
+                        );
128
+                        decor_tiles.insert((y as u32, x as u32), tile);
129
+                    }
130
+                }
131
+            }
132
+            LayerData::Infinite(_) => {
133
+                return GameResult::Err(GameError::ResourceLoadError(
134
+                    "Decor layer must be finite".to_string(),
135
+                ))
136
+            }
137
+        }
138
+
139
+        let decor = Decor::new(decor_layer, decor_tilesets, decor_images, decor_tiles);
140
+
170 141
         GameResult::Ok(Map {
171 142
             tiled_map: tiled_map.clone(),
172 143
             background_image: background_image.clone(),
173
-            terrain_image,
174
-            terrain_tileset,
175
-            tiles,
144
+            terrain,
145
+            decor,
176 146
         })
177 147
     }
178 148
 }

+ 190 - 0
src/map/terrain.rs View File

@@ -0,0 +1,190 @@
1
+use std::collections::HashMap;
2
+
3
+use ggez::{GameError, GameResult};
4
+use tiled::{Image as TiledImage, Layer, PropertyValue, Tileset};
5
+
6
+pub enum TerrainTileId {
7
+    ShortGrass,
8
+    MiddleGrass,
9
+    HighGrass,
10
+    Dirt,
11
+    Mud,
12
+    Concrete,
13
+    BrickWall,
14
+}
15
+
16
+pub struct TerrainTile {
17
+    pub id: TerrainTileId,
18
+    pub tile_width: u32,
19
+    pub tile_height: u32,
20
+    pub relative_tile_width: f32,
21
+    pub relative_tile_height: f32,
22
+    pub tile_x: u32,
23
+    pub tile_y: u32,
24
+    pub opacity: f32,
25
+}
26
+
27
+impl TerrainTile {
28
+    pub fn from_str_id(
29
+        id: &str,
30
+        tile_width: u32,
31
+        tile_height: u32,
32
+        relative_tile_width: f32,
33
+        relative_tile_height: f32,
34
+        tile_x: u32,
35
+        tile_y: u32,
36
+    ) -> Self {
37
+        match id {
38
+            "ShortGrass" => Self {
39
+                id: TerrainTileId::ShortGrass,
40
+                opacity: 0.0,
41
+                tile_width,
42
+                tile_height,
43
+                relative_tile_width,
44
+                relative_tile_height,
45
+                tile_x,
46
+                tile_y,
47
+            },
48
+            "MiddleGrass" => Self {
49
+                id: TerrainTileId::MiddleGrass,
50
+                opacity: 0.1,
51
+                tile_width,
52
+                tile_height,
53
+                relative_tile_width,
54
+                relative_tile_height,
55
+                tile_x,
56
+                tile_y,
57
+            },
58
+            "HighGrass" => Self {
59
+                id: TerrainTileId::HighGrass,
60
+                opacity: 0.2,
61
+                tile_width,
62
+                tile_height,
63
+                relative_tile_width,
64
+                relative_tile_height,
65
+                tile_x,
66
+                tile_y,
67
+            },
68
+            "Dirt" => Self {
69
+                id: TerrainTileId::Dirt,
70
+                opacity: 0.0,
71
+                tile_width,
72
+                tile_height,
73
+                relative_tile_width,
74
+                relative_tile_height,
75
+                tile_x,
76
+                tile_y,
77
+            },
78
+            "Mud" => Self {
79
+                id: TerrainTileId::Mud,
80
+                opacity: 0.1,
81
+                tile_width,
82
+                tile_height,
83
+                relative_tile_width,
84
+                relative_tile_height,
85
+                tile_x,
86
+                tile_y,
87
+            },
88
+            "Concrete" => Self {
89
+                id: TerrainTileId::Concrete,
90
+                opacity: 0.0,
91
+                tile_width,
92
+                tile_height,
93
+                relative_tile_width,
94
+                relative_tile_height,
95
+                tile_x,
96
+                tile_y,
97
+            },
98
+            "BrickWall" => Self {
99
+                id: TerrainTileId::BrickWall,
100
+                opacity: 1.0,
101
+                tile_width,
102
+                tile_height,
103
+                relative_tile_width,
104
+                relative_tile_height,
105
+                tile_x,
106
+                tile_y,
107
+            },
108
+            &_ => {
109
+                // FIXME BS NOW: manage errors
110
+                panic!("Unknown tile id {}", id)
111
+            }
112
+        }
113
+    }
114
+}
115
+
116
+pub struct Terrain {
117
+    pub tileset: Tileset,
118
+    pub layer: Layer,
119
+    pub image: TiledImage,
120
+    // FIXME (u32, u32) -> GridPoint
121
+    pub tiles: HashMap<(u32, u32), TerrainTile>,
122
+}
123
+
124
+impl Terrain {
125
+    pub fn new(
126
+        tileset: Tileset,
127
+        layer: Layer,
128
+        image: TiledImage,
129
+        tiles: HashMap<(u32, u32), TerrainTile>,
130
+    ) -> Self {
131
+        Self {
132
+            tileset,
133
+            layer,
134
+            image,
135
+            tiles,
136
+        }
137
+    }
138
+}
139
+
140
+pub fn get_tile_from_terrain_tileset_with_id(
141
+    terrain_tileset: &Tileset,
142
+    id: u32,
143
+    terrain_image_width: u32,
144
+    terrain_image_height: u32,
145
+) -> GameResult<TerrainTile> {
146
+    for tile in terrain_tileset.tiles.iter() {
147
+        if tile.id == id - terrain_tileset.first_gid {
148
+            let str_id = match tile.properties.get("ID") {
149
+                None => {
150
+                    return GameResult::Err(GameError::ResourceLoadError(format!(
151
+                        "Tile {} have no ID property",
152
+                        id
153
+                    )))
154
+                }
155
+                Some(property_value) => match property_value {
156
+                    PropertyValue::StringValue(str_id) => str_id.clone(),
157
+                    _ => {
158
+                        return GameResult::Err(GameError::ResourceLoadError(format!(
159
+                            "Tile {} must have String ID property value",
160
+                            id
161
+                        )))
162
+                    }
163
+                },
164
+            };
165
+
166
+            let tile_width = terrain_tileset.tile_width;
167
+            let tile_height = terrain_tileset.tile_height;
168
+            let relative_tile_width = tile_width as f32 / terrain_image_width as f32;
169
+            let relative_tile_height = tile_height as f32 / terrain_image_height as f32;
170
+            let len_by_width = terrain_image_width / tile_width;
171
+            let tile_y = tile.id / len_by_width;
172
+            let tile_x = tile.id - (tile_y * len_by_width);
173
+
174
+            return GameResult::Ok(TerrainTile::from_str_id(
175
+                &str_id,
176
+                tile_width,
177
+                tile_height,
178
+                relative_tile_width,
179
+                relative_tile_height,
180
+                tile_x,
181
+                tile_y,
182
+            ));
183
+        }
184
+    }
185
+
186
+    return GameResult::Err(GameError::ResourceLoadError(format!(
187
+        "No tile with {} found",
188
+        id
189
+    )));
190
+}

+ 0 - 109
src/map/tile.rs View File

@@ -1,109 +0,0 @@
1
-pub enum TileId {
2
-    ShortGrass,
3
-    MiddleGrass,
4
-    HighGrass,
5
-    Dirt,
6
-    Mud,
7
-    Concrete,
8
-    BrickWall,
9
-}
10
-
11
-pub struct Tile {
12
-    pub id: TileId,
13
-    pub tile_width: u32,
14
-    pub tile_height: u32,
15
-    pub relative_tile_width: f32,
16
-    pub relative_tile_height: f32,
17
-    pub tile_x: u32,
18
-    pub tile_y: u32,
19
-    pub opacity: f32,
20
-}
21
-
22
-impl Tile {
23
-    pub fn from_str_id(
24
-        id: &str,
25
-        tile_width: u32,
26
-        tile_height: u32,
27
-        relative_tile_width: f32,
28
-        relative_tile_height: f32,
29
-        tile_x: u32,
30
-        tile_y: u32,
31
-    ) -> Self {
32
-        match id {
33
-            "ShortGrass" => Self {
34
-                id: TileId::ShortGrass,
35
-                opacity: 0.0,
36
-                tile_width,
37
-                tile_height,
38
-                relative_tile_width,
39
-                relative_tile_height,
40
-                tile_x,
41
-                tile_y,
42
-            },
43
-            "MiddleGrass" => Self {
44
-                id: TileId::MiddleGrass,
45
-                opacity: 0.1,
46
-                tile_width,
47
-                tile_height,
48
-                relative_tile_width,
49
-                relative_tile_height,
50
-                tile_x,
51
-                tile_y,
52
-            },
53
-            "HighGrass" => Self {
54
-                id: TileId::HighGrass,
55
-                opacity: 0.2,
56
-                tile_width,
57
-                tile_height,
58
-                relative_tile_width,
59
-                relative_tile_height,
60
-                tile_x,
61
-                tile_y,
62
-            },
63
-            "Dirt" => Self {
64
-                id: TileId::Dirt,
65
-                opacity: 0.0,
66
-                tile_width,
67
-                tile_height,
68
-                relative_tile_width,
69
-                relative_tile_height,
70
-                tile_x,
71
-                tile_y,
72
-            },
73
-            "Mud" => Self {
74
-                id: TileId::Mud,
75
-                opacity: 0.1,
76
-                tile_width,
77
-                tile_height,
78
-                relative_tile_width,
79
-                relative_tile_height,
80
-                tile_x,
81
-                tile_y,
82
-            },
83
-            "Concrete" => Self {
84
-                id: TileId::Concrete,
85
-                opacity: 0.0,
86
-                tile_width,
87
-                tile_height,
88
-                relative_tile_width,
89
-                relative_tile_height,
90
-                tile_x,
91
-                tile_y,
92
-            },
93
-            "BrickWall" => Self {
94
-                id: TileId::BrickWall,
95
-                opacity: 1.0,
96
-                tile_width,
97
-                tile_height,
98
-                relative_tile_width,
99
-                relative_tile_height,
100
-                tile_x,
101
-                tile_y,
102
-            },
103
-            &_ => {
104
-                // FIXME BS NOW: manage errors
105
-                panic!("Unknown tile id {}", id)
106
-            }
107
-        }
108
-    }
109
-}

+ 142 - 0
src/map/util.rs View File

@@ -0,0 +1,142 @@
1
+use core::option::Option::{None, Some};
2
+use ggez::error::{GameError, GameResult};
3
+use ggez::GameError::GamepadError;
4
+use tiled::{Image as TiledImage, Layer, LayerData, Map as TiledMap, Tile as TiledTile, Tileset};
5
+
6
+pub fn extract_image_from_image_layer(
7
+    tiled_map: &TiledMap,
8
+    layer_name: &str,
9
+) -> GameResult<TiledImage> {
10
+    for image_layer in tiled_map.image_layers.iter() {
11
+        if image_layer.name == layer_name {
12
+            return match &image_layer.image {
13
+                None => GameResult::Err(GameError::ResourceLoadError(format!(
14
+                    "No image in image layer {}",
15
+                    layer_name
16
+                ))),
17
+                Some(image) => GameResult::Ok(image.clone()),
18
+            };
19
+        }
20
+    }
21
+
22
+    return GameResult::Err(GameError::ResourceLoadError(format!(
23
+        "Image layer {} not found in map ",
24
+        layer_name
25
+    )));
26
+}
27
+
28
+pub fn extract_image_from_tileset(tileset: &Tileset) -> GameResult<TiledImage> {
29
+    match tileset.images.first() {
30
+        None => {
31
+            return GameResult::Err(GameError::ResourceLoadError(
32
+                "No image found in givenn tileset".to_string(),
33
+            ))
34
+        }
35
+        Some(terrain_image) => GameResult::Ok(terrain_image.clone()),
36
+    }
37
+}
38
+
39
+pub fn extract_tileset(tiled_map: &TiledMap, tileset_name: &str) -> GameResult<Tileset> {
40
+    match tiled_map
41
+        .tilesets
42
+        .clone()
43
+        .into_iter()
44
+        .filter(|t| t.name == tileset_name)
45
+        .collect::<Vec<Tileset>>()
46
+        .first()
47
+    {
48
+        None => {
49
+            return GameResult::Err(GameError::ResourceLoadError(format!(
50
+                "No tileset {} found in map ",
51
+                tileset_name
52
+            )))
53
+        }
54
+        Some(tileset) => GameResult::Ok(tileset.clone()),
55
+    }
56
+}
57
+
58
+pub fn extract_layer(tiled_map: &TiledMap, layer_name: &str) -> GameResult<Layer> {
59
+    match tiled_map
60
+        .layers
61
+        .clone()
62
+        .into_iter()
63
+        .filter(|l| l.name == layer_name)
64
+        .collect::<Vec<Layer>>()
65
+        .first()
66
+    {
67
+        None => {
68
+            return GameResult::Err(GameError::ResourceLoadError(format!(
69
+                "No {} layer found in map",
70
+                layer_name
71
+            )))
72
+        }
73
+        Some(layer) => GameResult::Ok(layer.clone()),
74
+    }
75
+}
76
+
77
+pub fn extract_gids(layer: &Layer) -> GameResult<Vec<u32>> {
78
+    let mut gids: Vec<u32> = vec![];
79
+
80
+    match &layer.tiles {
81
+        LayerData::Finite(layer_tiles) => {
82
+            for (x, tiles_row) in layer_tiles.iter().enumerate() {
83
+                for (y, layer_tile) in tiles_row.iter().enumerate() {
84
+                    if !gids.contains(&layer_tile.gid) {
85
+                        gids.push(layer_tile.gid);
86
+                    }
87
+                }
88
+            }
89
+        }
90
+        LayerData::Infinite(_) => {
91
+            return GameResult::Err(GameError::ResourceLoadError(
92
+                "Layer must be finite".to_string(),
93
+            ))
94
+        }
95
+    }
96
+
97
+    GameResult::Ok(gids)
98
+}
99
+
100
+pub fn get_tileset_i_for_gid(gid: u32, tilesets: &Vec<Tileset>) -> GameResult<usize> {
101
+    for (i, tileset) in tilesets.iter().enumerate() {
102
+        if gid >= tileset.first_gid && gid < tileset.first_gid + tileset.tilecount.unwrap() {
103
+            return GameResult::Ok(i);
104
+        }
105
+    }
106
+
107
+    return GameResult::Err(GameError::ResourceLoadError(format!(
108
+        "gid {} not found for given tilesets",
109
+        gid
110
+    )));
111
+}
112
+
113
+pub fn extract_tilesets_containing_gids(
114
+    tiled_map: &TiledMap,
115
+    decor_tile_gids: Vec<u32>,
116
+) -> Vec<Tileset> {
117
+    let mut tilesets: Vec<Tileset> = vec![];
118
+
119
+    for tileset in tiled_map.tilesets.iter() {
120
+        for decor_tile_gid in &decor_tile_gids {
121
+            if *decor_tile_gid >= tileset.first_gid
122
+                && *decor_tile_gid < tileset.first_gid + tileset.tilecount.unwrap()
123
+            {
124
+                if !tilesets.contains(&tileset) {
125
+                    tilesets.push(tileset.clone());
126
+                }
127
+            }
128
+        }
129
+    }
130
+
131
+    tilesets
132
+}
133
+
134
+pub fn extract_tileset_images(tilesets: &Vec<Tileset>) -> GameResult<Vec<TiledImage>> {
135
+    let mut images: Vec<TiledImage> = vec![];
136
+
137
+    for tileset in tilesets.iter() {
138
+        images.push(extract_image_from_tileset(tileset)?)
139
+    }
140
+
141
+    GameResult::Ok(images)
142
+}

+ 2 - 2
src/physics/util.rs View File

@@ -4,8 +4,8 @@ use crate::{ScenePoint, WindowPoint};
4 4
 
5 5
 pub fn grid_position_from_scene_point(position: &ScenePoint, map: &Map) -> GridPoint {
6 6
     GridPoint::new(
7
-        (position.x / map.terrain_tileset.tile_width as f32) as i32,
8
-        (position.y / map.terrain_tileset.tile_height as f32) as i32,
7
+        (position.x / map.terrain.tileset.tile_width as f32) as i32,
8
+        (position.y / map.terrain.tileset.tile_height as f32) as i32,
9 9
     )
10 10
 }
11 11
 

+ 1 - 1
src/scene/main.rs View File

@@ -95,7 +95,7 @@ impl MainState {
95 95
         let ui_image = graphics::Image::new(ctx, "/ui.png")?;
96 96
         let ui_batch = graphics::spritebatch::SpriteBatch::new(ui_image);
97 97
 
98
-        let terrain_image = graphics::Image::new(ctx, format!("/{}", map.terrain_image.source))?;
98
+        let terrain_image = graphics::Image::new(ctx, format!("/{}", map.terrain.image.source))?;
99 99
         let mut debug_terrain_batch = graphics::spritebatch::SpriteBatch::new(terrain_image);
100 100
         debug_terrain_batch = scene::util::update_terrain_batch(debug_terrain_batch, &map);
101 101
         let debug_terrain_opacity_mesh_builder =

+ 2 - 2
src/scene/util.rs View File

@@ -9,7 +9,7 @@ pub fn update_terrain_batch(
9 9
     map: &Map,
10 10
 ) -> graphics::spritebatch::SpriteBatch {
11 11
     terrain_batch.clear();
12
-    for ((grid_x, grid_y), tile) in map.tiles.iter() {
12
+    for ((grid_x, grid_y), tile) in map.terrain.tiles.iter() {
13 13
         // FIXME pre compute these data ?
14 14
         let src_x = tile.tile_x as f32 * tile.relative_tile_width;
15 15
         let src_y = tile.tile_y as f32 * tile.relative_tile_height;
@@ -32,7 +32,7 @@ pub fn update_terrain_batch(
32 32
 
33 33
 pub fn create_debug_terrain_opacity_mesh_builder(map: &Map) -> GameResult<MeshBuilder> {
34 34
     let mut debug_terrain_opacity_mesh = MeshBuilder::new();
35
-    for ((grid_x, grid_y), tile) in map.tiles.iter() {
35
+    for ((grid_x, grid_y), tile) in map.terrain.tiles.iter() {
36 36
         let dest_x = *grid_x as f32 * tile.tile_width as f32;
37 37
         let dest_y = *grid_y as f32 * tile.tile_height as f32;
38 38
         let color_modifier = 0.6 * tile.opacity;