igorfs10 / rust_hero

Um jogo simples em rust
GNU General Public License v3.0
4 stars 1 forks source link

serde for SVG images (configurable characters) #13

Open 1sra3l opened 2 years ago

1sra3l commented 2 years ago

Hi, I was thinking a good way to accomplish configurable characters (body shape, outfit, hair, color) would be to use SVG files. SVG is xml, so serde is supported in quiet a few crates. I was thinking about using the "group" <g /> part of the SVG and name it body shape, outfit, hair and using the fill for color. I rarely use stroke in this type of vector art, so fill would be the only property to check specifically.

I could make a single file for each "outfit", "hair", and "body shape", then we could use FLTK's built in color chooser to change the color. I think it would be best to use the "with_default" to get the current fill each time the user opened it, it is much easier to fine tune a color choice.

I think this is about the only way to get that level of configuration for each part.

struct SvgHolder {
// the serde xml file
  image:Xml,
// the fltk Color
  color:Color,
// group we are changing
  group:String,
}
impl SvgHolder {
  fn set_color(c:Color);
  fn set_group(g:Group);
  fn svg()->Xml {
  //TODO
  };
}
struct Image {
  hair:SvgHolder,
  shape:SvgHolder,
  outfit:SvgHolder,
}
1sra3l commented 2 years ago

I made a vector sprite sheet that is very simple. My goal is to make a simple rag-doll that can be layered upon programatically, and have the interior fill/stroke be configurable. rpg-kid-vec @igorfs10 What animations do you want? Do you want a full 360 set like the animation?

igorfs10 commented 2 years ago

Great.

Just walking to right and attacking. 👍

1sra3l commented 2 years ago

@igorfs10 I am messing with some things in my own time and will experiment with things more fully in my random creature math game. I think I will use randomness to choose top/bottom of animal images when I really get further along.

I am breaking rpgstat in a big way. I added a f64 Stat and "creature". I am moving randomization into character creation, rather than using "premade". I think random is nicer for people. It gives "out-of-the-box" functionality for people who just want to make something fit in their code, but tack on a serde later. This is why I had so much useless other code.

1sra3l commented 2 years ago

I have started work on dynamic building of a face vector graphic. image It looks like a muppet currently, but I think once I get further along it will be nice to have a custom image. My hope is to make creatures/characters randomly. I think drawing poses and making them have interchangeable parts will make it much easier to create a wider range of characters/creatures.

What do you think?

igorfs10 commented 2 years ago

That is great, it looks funny, but I like it. Waiting to see how they will look

1sra3l commented 2 years ago

@igorfs10 I decided to move the vector code into a library. Updated version I also have initial body, as well as a few initial variations. I am streamlining the code and will soon move things into modules to make more types of {noses, ears, eyes, etc...}. I also have a minimal set of expressions and can implement things more

I made a "rpg" feature of vectorview to use with rpgstat and will use it to draw Icons for things like "type" or "effect" In theory, I could likely make backgrounds for "Locations", but that will be a while after I get the "character" and "creature" drawing more stable.

I think this will be really great for a user to change the character to suit them, though it is still very early.

1sra3l commented 2 years ago

I got to work on modules and begun building animal heads. The face is also taking shape, as well as initial work on building bodies. This is looking more and more like the best way to create a bunch of art.