use built-in debug macros
This commit is contained in:
parent
47a9259526
commit
9e7dffa516
61
src/main.rs
61
src/main.rs
|
@ -4,26 +4,26 @@ use std::collections::HashMap;
|
||||||
const IMAGE_DIMENSION_SD: usize = 8;
|
const IMAGE_DIMENSION_SD: usize = 8;
|
||||||
const IMAGE_DIMENSION_HD: usize = 16;
|
const IMAGE_DIMENSION_HD: usize = 16;
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Colour {
|
struct Colour {
|
||||||
red: u8,
|
red: u8,
|
||||||
green: u8,
|
green: u8,
|
||||||
blue: u8,
|
blue: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Palette {
|
struct Palette {
|
||||||
id: String, // base36 string (why??)
|
id: String, // base36 string (why??)
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
colours: Vec<Colour>,
|
colours: Vec<Colour>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Image {
|
struct Image {
|
||||||
pixels: Vec<u8>, // 64 for SD, 256 for HD
|
pixels: Vec<u8>, // 64 for SD, 256 for HD
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Tile {
|
struct Tile {
|
||||||
id: String, // base36 string
|
id: String, // base36 string
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
@ -38,13 +38,13 @@ struct Position {
|
||||||
y: u8,
|
y: u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Dialogue {
|
struct Dialogue {
|
||||||
id: String,
|
id: String,
|
||||||
contents: String,
|
contents: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Sprite {
|
struct Sprite {
|
||||||
id: String, // lowercase base36
|
id: String, // lowercase base36
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
@ -54,13 +54,13 @@ struct Sprite {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// avatar is a "sprite" in the game data but with a specific ID
|
/// avatar is a "sprite" in the game data but with a specific ID
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Avatar {
|
struct Avatar {
|
||||||
animation_frames: Vec<Image>,
|
animation_frames: Vec<Image>,
|
||||||
position: Position,
|
position: Position,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Item {
|
struct Item {
|
||||||
id: String,
|
id: String,
|
||||||
animation_frames: Vec<Image>,
|
animation_frames: Vec<Image>,
|
||||||
|
@ -68,7 +68,7 @@ struct Item {
|
||||||
dialogue: Option<Dialogue>,
|
dialogue: Option<Dialogue>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Exit {
|
struct Exit {
|
||||||
/// destination
|
/// destination
|
||||||
room: String, /// id
|
room: String, /// id
|
||||||
|
@ -76,12 +76,12 @@ struct Exit {
|
||||||
}
|
}
|
||||||
|
|
||||||
// same as a dialogue basically
|
// same as a dialogue basically
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Ending {
|
struct Ending {
|
||||||
contents: String,
|
contents: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
struct Room {
|
struct Room {
|
||||||
id: String,
|
id: String,
|
||||||
palette: String, /// id
|
palette: String, /// id
|
||||||
|
@ -100,45 +100,6 @@ struct Game {
|
||||||
palettes: Vec<Palette>,
|
palettes: Vec<Palette>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Colour {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Colour")
|
|
||||||
.field("red", &self.red)
|
|
||||||
.field("green", &self.green)
|
|
||||||
.field("blue", &self.blue)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Palette {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Palette")
|
|
||||||
.field("id", &self.id)
|
|
||||||
.field("name", &self.name)
|
|
||||||
.field("colours", &self.colours)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Image")
|
|
||||||
.field("pixels", &self.pixels)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for Tile {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
f.debug_struct("Tile")
|
|
||||||
.field("id", &self.id)
|
|
||||||
.field("name", &self.name)
|
|
||||||
.field("wall", &self.wall)
|
|
||||||
.field("animation_frames", &self.animation_frames)
|
|
||||||
.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn image_from_string(string: String) -> Image {
|
fn image_from_string(string: String) -> Image {
|
||||||
let string = string.replace("\n", "");
|
let string = string.replace("\n", "");
|
||||||
let pixels: Vec<&str> = string.split("").collect();
|
let pixels: Vec<&str> = string.split("").collect();
|
||||||
|
|
Loading…
Reference in New Issue