That tutorial is on the basic math of rotation. How to rotate a single point in space. In order to properly rotate an entire sprite, as papa mentioned, you need to draw the sprite as textured geometry, and then rotate that geometry. It's an advanced topic for you right now, I say leave it.Yumtard wrote:Nope wasn't able to figure out how to implement rotation. The code used in the video has a bunch of other stuff, polyclosed and other ways to draw.
So couldn't figure out how to use
Vec2 Vec2::Rotation(const float angle) const
{
Vec2 result;
float cosine = cosf(angle);
float sine = sinf(angle);
result.x = x * cosine - y * sine;
result.y = x * sine + y * cosine;
return result;
}
to actually rotate my sprites.
My feeble brain also had some trouble following the maths, would probably need another watch to understand it all.
Anyways gonna take a break and then figure out what else I can do instead
You can use the point rotation to do rotational movement of sprite, but leave the sprites themselves in the same orientation. If you need rotation, create n sprite frames for each angle of rotation you want (maybe 16/32 frames will give you fairly fine-grained rotation).
In your next game in sfml, you can do rotation easy without understanding the underlying concepts. Leave the exercise of doing it yourself until you are a little more advanced. Did you at least understand the principle of rotating a point in space?