remove avatar (treat it as sprite)

This commit is contained in:
Max Bradbury 2020-06-18 17:46:30 +01:00
parent 4430ee74aa
commit bf5b3a8d20
2 changed files with 35 additions and 41 deletions

View File

@ -78,7 +78,6 @@ pub struct Game {
pub palettes: Vec<Palette>, pub palettes: Vec<Palette>,
pub rooms: Vec<Room>, pub rooms: Vec<Room>,
pub tiles: Vec<Tile>, pub tiles: Vec<Tile>,
pub avatar: Sprite,
pub sprites: Vec<Sprite>, pub sprites: Vec<Sprite>,
pub items: Vec<Item>, pub items: Vec<Item>,
pub dialogues: Vec<Dialogue>, pub dialogues: Vec<Dialogue>,
@ -167,8 +166,6 @@ impl Game {
rooms.push(Room::from(segment)); rooms.push(Room::from(segment));
} else if segment.starts_with("TIL ") { } else if segment.starts_with("TIL ") {
tiles.push(Tile::from(segment)); tiles.push(Tile::from(segment));
} else if segment.starts_with("SPR A") {
avatar = Some(Sprite::from(segment));
} else if segment.starts_with("SPR ") { } else if segment.starts_with("SPR ") {
sprites.push(Sprite::from(segment)); sprites.push(Sprite::from(segment));
} else if segment.starts_with("ITM ") { } else if segment.starts_with("ITM ") {
@ -187,9 +184,7 @@ impl Game {
} }
} }
// todo return a custom error instead // todo check if SPR A (avatar) exists
assert!(avatar.is_some());
let avatar = avatar.unwrap();
Ok( Ok(
Game { Game {
@ -203,7 +198,6 @@ impl Game {
palettes, palettes,
rooms, rooms,
tiles, tiles,
avatar,
sprites, sprites,
items, items,
dialogues, dialogues,
@ -278,8 +272,6 @@ impl ToString for Game {
} }
} }
segments.push(self.avatar.to_string().replace("SPR a", "SPR A"));
for sprite in &self.sprites { for sprite in &self.sprites {
if !is_string_numeric(sprite.id.clone()) { if !is_string_numeric(sprite.id.clone()) {
segments.push(sprite.to_string()); segments.push(sprite.to_string());

View File

@ -767,38 +767,40 @@ pub fn game_default() -> Game {
walls: vec![], walls: vec![],
}], }],
tiles: vec![self::tile_default()], tiles: vec![self::tile_default()],
avatar: Sprite { sprites: vec![
id: "A".to_string(), Sprite {
animation_frames: vec![Image { id: "A".to_string(),
pixels: vec![ animation_frames: vec![Image {
0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, pixels: vec![
1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0,
], 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
}], ],
name: None, }],
room_id: Some("0".to_string()), name: None,
position: Option::from(Position { x: 4, y: 4 }), room_id: Some("0".to_string()),
colour_id: None, position: Option::from(Position { x: 4, y: 4 }),
dialogue_id: None, colour_id: None,
items: vec![] dialogue_id: None,
}, items: vec![]
sprites: vec![Sprite { },
id: "a".to_string(), Sprite {
name: None, id: "a".to_string(),
animation_frames: vec![Image { name: None,
pixels: vec![ animation_frames: vec![Image {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, pixels: vec![
1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1,
1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1,
], 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
}], ],
dialogue_id: Some("SPR_0".to_string()), }],
room_id: Some("0".to_string()), dialogue_id: Some("SPR_0".to_string()),
position: Some(Position { x: 8, y: 12 }), room_id: Some("0".to_string()),
colour_id: None, position: Some(Position { x: 8, y: 12 }),
items: vec![] colour_id: None,
}], items: vec![]
},
],
items: vec![Item { items: vec![Item {
id: "0".to_string(), id: "0".to_string(),
animation_frames: vec![Image { animation_frames: vec![Image {