[SOLVED] Sprite recolouring / modification in-engine (for character creator)?

Started by Hobbes, Wed 20/04/2022 02:56:48

Previous topic - Next topic

Hobbes

Hi everyone,

I'm trying to think through if something is feasible / possible...

I would like to have a Character Creator for my Adventure/RPG hybrid. The most basic way I can think about this is defining certain views for each iteration, which would mean that, let's say:

- Character with long hair (char1)
- Character with short hair (char2)

I would need to create separate views for everything, so "char.climbing" also needs a "char2.climbing" "char.sitting" also needs a "char2.sitting".

As soon as I want to do iterations on skin tone, clothing colour, it becomes... a lot.

I was wondering if there was a way in AGS to combine multiple views? Or dynamically generate a sprite? Or recolour a given RGB value from a sprite/view?

That way skin tone could be mapped to a GUI-Button. And when you click button1, it reads all the RGB values to colour the sprite one skin tone. (I use 3 to 4 different colours for skin, for shading).

That would potentially work for recolouring a sprite. Does AGS have this feature?

For more dynamic changes, like hairstyles, it would mean I need to superimpose another view on top of another, which sounds like an impossibility probably.

Any ideas/suggestions on how to explore this a bit further would be most appreciated. Fully appreciate it might be an impossibility anyway. :-)

Thanks!

Crimson Wizard

Quote from: Hobbes on Wed 20/04/2022 02:56:48
I was wondering if there was a way in AGS to combine multiple views?

Usually this is done by combining multiple objects or characters together. See Character.FollowCharacter, alternative is to update positions of other "parts" in repeatedly_execute (or similar) to follow the main "body" character.

Quote from: Hobbes on Wed 20/04/2022 02:56:48
Or dynamically generate a sprite? Or recolour a given RGB value from a sprite/view?

Yes, see DynamicSprite and DrawingSurface articles:
https://github.com/adventuregamestudio/ags-manual/wiki/DynamicSprite
https://github.com/adventuregamestudio/ags-manual/wiki/DrawingSurface


EDIT: also, forgot to mention previously: it's not possible to generate Views, but it's possible to replace the frames:
Code: ags

ViewFrame* vf = Game.GetViewFrame(view, loop, frame);
vf.Graphic = NEW_SPRITE_NUM;

Hobbes

Thanks for the explanation. I'll dive in and have a look. Sounds like there's enough possibilities to make this happen (potentially). :-)

fratello Manu

Hi everyone.

I have the same need and I'd like to try a different solution. Let's see if it can work!

Is it possible to 'import' spritesheets at runtime?

in this way we could have a stand-alone characters sprites generator (maybe another ags application, or a c# application, or something in python, who knows) which would overlap bodies, clothes, etc to generate a .png spritesheet. It could also write a json file with some details about character (char name, spritesheet file name, etc)

Then our game would allow player to select which character (or even more than one) to be imported.
Sprites would be grabbed from sheet (in a grid-wise layout) . As an alternative, we could have several .png files, one for every frame, with proper names in order to identify them.
Then these frames would be instanced as frames in our game and assigned to our views.

Crazy?

bye!

Crimson Wizard

Quote from: manu_controvento on Thu 28/04/2022 10:53:37
Is it possible to 'import' spritesheets at runtime?

Yes, you may create Dynamic Sprites from file using DynamicSprite.CreateFromFile function, and then cut them in pieces by creating an array of DynamicSprites and then either using Crop function, or if you're on AGS 3.6.0 the DrawImage can tell source rectangle too so it's possible to only draw tiles from the source image to the dest image.

The files may be loaded using File functions, but if these are json you will have to script a JSON parser in AGS. I think that there might be a JSON module somewhere, but I remember only IniFile module:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=46631.0

Quote from: manu_controvento on Thu 28/04/2022 10:53:37
Then these frames would be instanced as frames in our game and assigned to our views.

As I mentioned above you cannot create views or frames in script, you may only edit existing ones. So either you'd have to precreate necessary views and have a fixed number of frames. Or script your own animation system...

SMF spam blocked by CleanTalk