|
|
|
|
99
|
pub fn new(ctx: &mut Context) -> GameResult<MainState> {
|
99
|
pub fn new(ctx: &mut Context) -> GameResult<MainState> {
|
100
|
let map = Map::new(&Path::new("resources/map1.tmx"))?;
|
100
|
let map = Map::new(&Path::new("resources/map1.tmx"))?;
|
101
|
|
101
|
|
102
|
- // FIXME manage error
|
|
|
103
|
- let sprite_sheet_image = graphics::Image::new(ctx, "/sprite_sheet.png").unwrap();
|
|
|
|
|
102
|
+ let sprite_sheet_image = graphics::Image::new(ctx, "/sprite_sheet.png")?;
|
104
|
let sprite_sheet_batch = graphics::spritebatch::SpriteBatch::new(sprite_sheet_image);
|
103
|
let sprite_sheet_batch = graphics::spritebatch::SpriteBatch::new(sprite_sheet_image);
|
105
|
|
104
|
|
106
|
let map_image = graphics::Image::new(
|
105
|
let map_image = graphics::Image::new(
|
107
|
ctx,
|
106
|
ctx,
|
108
|
&Path::new(&format!("/{}", &map.background_image.source)),
|
107
|
&Path::new(&format!("/{}", &map.background_image.source)),
|
109
|
- )
|
|
|
110
|
- .unwrap();
|
|
|
|
|
108
|
+ )?;
|
111
|
let map_batch = graphics::spritebatch::SpriteBatch::new(map_image);
|
109
|
let map_batch = graphics::spritebatch::SpriteBatch::new(map_image);
|
112
|
|
110
|
|
113
|
- // FIXME manage error
|
|
|
114
|
- let ui_image = graphics::Image::new(ctx, "/ui.png").unwrap();
|
|
|
|
|
111
|
+ let ui_image = graphics::Image::new(ctx, "/ui.png")?;
|
115
|
let ui_batch = graphics::spritebatch::SpriteBatch::new(ui_image);
|
112
|
let ui_batch = graphics::spritebatch::SpriteBatch::new(ui_image);
|
116
|
|
113
|
|
117
|
- // FIXME manage error
|
|
|
118
|
- let terrain_image =
|
|
|
119
|
- graphics::Image::new(ctx, format!("/{}", map.terrain_image.source)).unwrap();
|
|
|
|
|
114
|
+ let terrain_image = graphics::Image::new(ctx, format!("/{}", map.terrain_image.source))?;
|
120
|
let mut terrain_batch = graphics::spritebatch::SpriteBatch::new(terrain_image);
|
115
|
let mut terrain_batch = graphics::spritebatch::SpriteBatch::new(terrain_image);
|
121
|
terrain_batch = update_terrain_batch(terrain_batch, &map);
|
116
|
terrain_batch = update_terrain_batch(terrain_batch, &map);
|
122
|
|
117
|
|