I am trying to make a game where the person can create their own character, but instead of using a character builder, i want the person to be able to draw their character. how do i code that in c# so that they only have to draw their character once, and the code can animate that character without the player having to do very much except draw their character on the screen?

  • \$\begingroup\$ If you pull this off and release it into the wild, be ready for a LOT of animated penises and swastikas. \$\endgroup\$ – Hackworth Sep 11 '12 at 15:38
  • \$\begingroup\$ Also, you provide very little detail on what you're trying to achieve. If a player can draw a character, it's just a different, if more potent kind of character builder, and the more freedom you want to give to the player, the more work you have to do. Giving a computer nothing but a totally free-form drawing and having it crank out a playable character model would be indistinguishable from magic nowadays. Start simple, with a pre-defined model and let players paint the textures or something like that. \$\endgroup\$ – Hackworth Sep 11 '12 at 15:49

One way to do it would be to make the character consist of different parts. I'm currently working on a 3D game, and I have written an exporter for Blender in Python that takes the currently active (selected) object and exports it's data and then goes recursively through all of the object's children and their children and so on, so I end up with a sort of a file with a tree like structure where there's one root object (the first one written) and the other ones are laid down after it, and they all have number of children written as part of their data so the parser (written in C) knows how to reconstruct the entire model tree so I can translate/rotate/scale any part and all it's children will have the same transformation applied.

So, I'd suggest doing a similar thing, just making things fixed. For example:

  • You have an interface where a user can draw a torso. Besides actual pixel data, you can also let them put where the head and extremities will be attached, sort of a pointer that they can drag around and place where they want. Then, when the user goes to draw the head of the character, he should be able to see the point where the head connects to the torso and draw around it. Same thing for legs and arms.
  • Then you can load that data (pixel values and joint positions) and draw them accordingly.
  • Animate them relative to their respecting marker's positions.
  • Something like this:

enter image description here

  • \$\begingroup\$ would it also be a good idea for them to draw out a character and then highlight the head, torso, etc with a selector tool? \$\endgroup\$ – Adam Geisweit Sep 11 '12 at 16:45
  • 2
    \$\begingroup\$ @AdamGeisweit Personally, I would have the joints/connection points pre-defined and the user can draw within those constraints. \$\endgroup\$ – MichaelHouse Sep 11 '12 at 17:38
  • \$\begingroup\$ @Byte56: That's probably a good idea - easier to implement and you don't have to check whether the player has placed all the joints. \$\endgroup\$ – Vladimir Mitrovic Sep 11 '12 at 20:06
  • \$\begingroup\$ @AdamGeisweit: You could set the initial pixels to a predefined color, like a shade of blue that will most likely not be used (human eye doesn't percept the blue color as well as red and green) to act as un-highlighted area. It is also wise to have a limited number of colors, e.g. the so called 'Web Safe Palette' - lynda.com/resources/webpalette.aspx. That way you save a lot of data, you can pack individual pixels in a single byte (the palette has 216 colors), and use the rest 40 values for things like transparency, special areas like glow and such if you later implement them. \$\endgroup\$ – Vladimir Mitrovic Sep 11 '12 at 20:16
  • \$\begingroup\$ @AdamGeisweit: But what you can do, is overlay a sort of mask over the canvas that will instruct them what's the best area to draw on. See pic: i.imgur.com/20pos.jpg \$\endgroup\$ – Vladimir Mitrovic Sep 11 '12 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.