2020-04-11 15:08:57 +00:00
|
|
|
# bitsy-parser
|
2020-04-05 17:58:04 +00:00
|
|
|
|
2020-04-18 16:00:03 +00:00
|
|
|
![Rust](https://github.com/synth-ruiner/bitsy-parser/workflows/Rust/badge.svg)
|
2020-04-18 16:05:37 +00:00
|
|
|
![](https://img.shields.io/badge/license-MIT-blueviolet.svg)
|
|
|
|
[![Crates.io](https://img.shields.io/crates/v/bitsy-parser.svg)](https://crates.io/crates/bitsy-parser)
|
2020-04-18 16:00:03 +00:00
|
|
|
|
2020-04-05 17:58:04 +00:00
|
|
|
a library for parsing Bitsy game data.
|
|
|
|
|
2020-04-12 13:48:43 +00:00
|
|
|
the version number follows Bitsy itself, so version 0.65.* targets Bitsy 6.5.
|
|
|
|
|
2020-04-12 16:13:08 +00:00
|
|
|
## how to use
|
|
|
|
|
2020-04-13 18:28:22 +00:00
|
|
|
a simple example program:
|
|
|
|
|
2020-04-12 16:13:08 +00:00
|
|
|
```rust
|
|
|
|
extern crate bitsy_parser;
|
|
|
|
use std::{env, fs};
|
|
|
|
use bitsy_parser::game::Game;
|
|
|
|
use bitsy_parser::image::Image;
|
|
|
|
|
|
|
|
/// replaces the player avatar with a smiley face.
|
|
|
|
fn main() {
|
|
|
|
let input_file = env::args().nth(1)
|
2020-04-12 16:17:39 +00:00
|
|
|
.expect("No input path specified. Usage: `smiley infile outfile`");
|
2020-04-12 16:13:08 +00:00
|
|
|
let output_file = env::args().nth(2)
|
2020-04-12 16:17:39 +00:00
|
|
|
.expect("No output path specified. Usage: `smiley infile outfile`");
|
2020-04-12 16:13:08 +00:00
|
|
|
|
2020-04-19 06:28:52 +00:00
|
|
|
let mut game = Game::from(fs::read_to_string(input_file).unwrap()).unwrap();
|
2020-04-12 16:13:08 +00:00
|
|
|
|
|
|
|
game.avatar.animation_frames = vec![
|
|
|
|
Image {
|
|
|
|
pixels: vec![
|
|
|
|
0,0,1,1,1,1,0,0,
|
|
|
|
0,1,1,1,1,1,1,0,
|
|
|
|
1,1,0,1,1,0,1,1,
|
|
|
|
1,1,0,1,1,0,1,1,
|
|
|
|
1,1,1,1,1,1,1,1,
|
|
|
|
1,1,0,1,1,0,1,1,
|
|
|
|
0,1,1,0,0,1,1,0,
|
|
|
|
0,0,1,1,1,1,0,0,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
fs::write(output_file, &game.to_string())
|
|
|
|
.expect("Failed to write to output file");
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
some more practical uses would be things like:
|
|
|
|
|
|
|
|
* remove duplicate tiles
|
|
|
|
* merge two Bitsy games together
|
|
|
|
* programmatically create Bitsy games
|
|
|
|
* a Bitsy game editor
|
|
|
|
|
2020-04-05 17:58:04 +00:00
|
|
|
## todo
|
|
|
|
|
2020-04-15 08:08:34 +00:00
|
|
|
* test for bitsy 7.0 and implement new features
|
2020-04-23 07:57:30 +00:00
|
|
|
* titles can have multiple lines of dialog
|
|
|
|
* dialogue names
|
2020-04-13 23:41:28 +00:00
|
|
|
* implement Result return types on ::from functions so we can handle errors
|
2020-04-18 12:59:48 +00:00
|
|
|
* handle old out-of-bounds editor errors (extra image pixels, exits/endings with position -1,-0 etc.)
|
|
|
|
* it's ok if the output of these does not match the input as we're fixing it
|
2020-04-23 11:07:14 +00:00
|
|
|
* add Bitsy HD and Bitsy 7.0 test data
|
2020-04-24 17:09:18 +00:00
|
|
|
* fix variables/endings becoming "DLG DLG"?
|
2020-04-29 07:27:35 +00:00
|
|
|
* replace Image with Vec<u8> or something. seems like a pointless abstraction
|
2020-04-30 18:29:41 +00:00
|
|
|
* convert integer IDs to strings and just use base36 when creating new IDs; test games with arbitrary IDs
|
2020-04-13 23:41:28 +00:00
|
|
|
|
2020-04-05 18:04:17 +00:00
|
|
|
### tidy up
|
|
|
|
|
2020-04-12 13:38:07 +00:00
|
|
|
* refactor the more shonky bits to idiomatic rust
|