Cranking Out Characters
Hey there!
For this project, I want to have many characters that you meet through. For this, and as a way to learn Lua, I have decided to create a Random Character Generator. This is still work in progress but since I got to a point where I can make characters that feel... normal, I decided to share it here. 'Normal faces' is surprisingly difficult for someone who only works on environments usually. A rock can look anyway you want, a face, not so much...
The Template
First and foremost, I wanted to see what looks right on the Playdate. The console screen is smaller than the emulator at 1x scale, so the stuff I tried before the Playdate arrived ended up being off. Once the Playdate arrived on Tuesday, I put a few images on it at different scales until I found a size that worked.
From there, I have made this template where I draw everything on layers and just turn on/off elements to see how things play together.
I work on a version of this image scale up 4x where I draw all the elements. You can probably guess what each color is for, but basically:
Green for the head shapes, Purple for the hair/gear, Dark Blue for the beards, Red for the eyes, Pink for the eyebrows, Blue for the nose, Light Blue for the mouth and Yellow for the ears.
And it's that last element that I spent the most time wondering how to go about -- I could have just one ear and place it twice, but since the head width will not change, I have decided the waste in pixels is worth the possibility to have left and right ears looking slightly different, or a bit crooked, etc.
Another thing this template has been useful for is to gauge what distance (in pixels) each element should be from each other, so I can place them accordingly in Lua and then shift things around slightly to get some more variation.
When shifting things around, I have a base value...
faceOffset = math.random(-2, 8)
... that I multiply by 0.2 for the mouth, 0.8 for the nose and similar. That way the mouth doesn't end up smack in the middle of the chin, etc.
The Elements
For now I have not prepared too many variations of each element, but this is where I will have some fun in the next week or so. The one part that is a bit of an annoyance is doing the processing where I want dithers that blend with other elements (like the shadows on the helmets), but I also need areas that are fully opaque so other elements don't show through (like the top of the head showing through the head).
These are the current variations I have on my test. So many more to come:
Cranking 'em Out!
From here, I just spent a bit of time to figure out how to make it randomly generate these faces when moving the crank.
Kind of fun to see what faces come up!
I want to create a few more elements, as well as have an option to rotate the crank counter-clockwise to go through previously generated faces. That should be something fun to learn next.
The Debugger
I also worked on a tiny debugger to see what parts are being added. While I'm aware this is a very basic functionality, figuring out how to make it work in code took me a couple hours. But now at least if I see a configuration I like, I can replicate it easily!
This font for debug should definitely be monospace...
WIP Playdate Title
More posts
- A History LessonApr 06, 2024
- Figuring DitheringMar 23, 2024
- Trying LuaMar 21, 2024
- Making a Playdate gameMar 21, 2024
Leave a comment
Log in with itch.io to leave a comment.