Jump to content
  • Advertisement
Sign in to follow this  
Davi Doro

How to divide character body?

This topic is 2128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

So, I'm making a 2D platformer in C++ with SFML. To animate my characters I used a sprite sheet where each frame has a fixed size and each line of frames is associated with a movement (for now, they are IDLE, WALK, and JUMP)

 

Now I got to a point where I need the head of the character to rotate, and I'm having a hard time on figuring out a nice way to divide the body in separate pieces and draw them togheter.

 

Can someone help me on this?

Thx! smile.png

Share this post


Link to post
Share on other sites
Advertisement

I imagine you're already doing this, but have one instance draw all the pieces of their relative body. Don't have an instance for each piece.

As for the drawing of pieces, if you're using OpenGL, you want to rotate the piece first by the pieces desired rotation( the unique rotation of the head indifferent from the body ), translate the piece to the center of the instance, rotate again to the instances desired rotation( so rotating the entire character rotates the head with the rest of the body ).

If you have any specific questions, ask away as I'm not entirely sure how you're going about attempting to achieve your goal.

Share this post


Link to post
Share on other sites

For animation switching: States (dead state, walking state)

A "Scene Graph" in 2D (it's possible) it's definitely what you need. Just Google It! Your code will be more Object Oriented and more reusable too. cool.png

Edited by irlanrobson

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!