more structs and hashmaps
This commit is contained in:
parent
2f9a4f7fe3
commit
b7ff7c951c
27
src/main.rs
27
src/main.rs
|
@ -1,4 +1,5 @@
|
|||
use std::fmt;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Colour {
|
||||
|
@ -27,7 +28,7 @@ struct Tile {
|
|||
animation_frames: Vec<Image>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
#[derive(Eq, PartialEq, Hash)]
|
||||
struct Position {
|
||||
room: String, // id. is room id int or base36 string?
|
||||
x: u8,
|
||||
|
@ -49,6 +50,7 @@ struct Sprite {
|
|||
position: Position,
|
||||
}
|
||||
|
||||
/// avatar is a "sprite" in the game data but with a specific ID
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Avatar {
|
||||
animation_frames: Vec<Image>,
|
||||
|
@ -63,6 +65,29 @@ struct Item {
|
|||
dialogue: Option<Dialogue>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Exit {
|
||||
/// destination
|
||||
room: String, /// id
|
||||
position: Position,
|
||||
}
|
||||
|
||||
// same as a dialogue basically
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Ending {
|
||||
contents: String,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq)]
|
||||
struct Room {
|
||||
id: String,
|
||||
palette: String, /// id
|
||||
name: Option<String>,
|
||||
items: HashMap<Position, Item>,
|
||||
exits: HashMap<Position, Exit>,
|
||||
endings: HashMap<Position, Ending>,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Game {
|
||||
name: String,
|
||||
|
|
Loading…
Reference in New Issue