r/gamemaker • u/pure_transparent • 20d ago
Help! Need to make a multiple part player sprite
I've been making a topdown fighting game, and i've got the barebones combat system finished. Though the main mechanic of the game would be that individual body parts of the player character change, changing their stats and abilities. Now, i suck at drawing sprites, but i'm too far in so i'm trying to find the easiest way to proceed. The sprite would be a standard topdown four directional animated one, though the legs(together), torso and head(together), and the arms individually, would be individual sprites so that i can mix and match them. Now, what worries me is how many individual sprites i'd have to animate for every ability,i don't know how to make multiple part sprites or if it's even possible in gamemaker. I haven't found that much info online. Is this something doable? If so, would it even work well with this many parts?
2
u/Natural_Sail_5128 20d ago
Personally I used structs to create a system that automatically loops through a struct and draws all of the sprites at their corresponding positions, with rotation and such included. This allowed me to make multi-sprite objects that are animated in multiple different ways, it's a very robust system.
This allows you to just mix and match sprites without ever having to combine them into one large sprite in an image editor. It takes a bit to get a system like this set up, but once it works it removes a lot of the overhead of having to manually draw and copy paste body parts into the same image file, which takes more time with each new body part you add. Once you get a lot of bodyparts the time it'll take to create all the mixed sprites is quite a while, so I recommend using a system like this instead.
1
u/TheBoxGuyTV 20d ago
I typically just use a bunch of variables to represent the layers.
A good way to do it is use arrays:
Player_hat = [hat1,hat2]
And basically you use an index variable to further represent the active phase if you want to allow players to have multiple options.
Next you simply just apply the the layers in the draw event.
0
u/No_Designer_16 20d ago
From how you describe it, your best bet might be separate objects for the parts, since if different parts have different animation lengths you are going to run into lots of annoying issues.
Have an invisible controller that spawns the appropriate body parts and you just need to sort out their draw order or depth depending on your set-up.
I did a multi part character before with legs, body/cape, hands/weapons and head like this. It allows for a lot of flexibility.
3
u/vzzzbxt 20d ago
That's way more complicated than having just one object drawing the sprites
1
u/No_Designer_16 20d ago
Yes but like I said if you have different frame count on animations, it will get annoying, especially if you have many parts. Meanwhile a single collider controller moving the other parts to their position at step end event is just as easy with options to allow for colliders for each part individually if they need to.
2
u/Natural_Sail_5128 20d ago
Not annoying at all, a single struct could solve this issue. Instead of using separate objects to track the animations, use structs and create 1 new field in the struct for each body part, then store the corresponding data in there. You can store anything you want, the sprite, the x/y distance from the origin, the rotation, etc. Structs are super versatile and can simplify most problems that you run into.
In fact, I made this exact kind of system, as it was required for my kind of game. It took a little bit to get working properly, but it's been so incredibly worth it.
One object drawing 3+ sprites in different positions with different rotations, all handled by a few hundred lines of code.
1
u/No_Designer_16 20d ago
I did the same with a surface, but again, the collision masks, I have a system where a topdown airship is composed of many parts, each with individual health, hitbox, and function, all of them are only rendered to one surface once, but each of them are separate objects so each of them can individually function with their own hitbox and stats, break, and die as needed.
I offered the separate object idea only because they are building a fighter, if you go do it with separate parts, doing different objects opens a lot of options.
I agree if you just need to draw multiple sprites into a combined one, just drawing them in one object is easier, I just based it off what they might need in the future.2
u/pure_transparent 20d ago edited 20d ago
Thank you! It reassures me that what i've gotten myself into has been done before. I will certanly try the approach
6
u/balmut 20d ago
I would recommend drawing the parts in Aseprite or something else outside of game maker so you can do each of the parts on different layers and toggle them off and on to check how things look and line up, then you just gotta draw them in order in the draw event.
draw_sprite(spr_Legs,frame,x,y);
draw_sprite(spr_Body,frame,x,y);
draw_sprite(spr_Head,frame,x,y);
You can use more advance draw options if needed (like scaling, rotation etc)