Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DarthDuck

Pages: [1]
1
General / Adding hitboxes/shapes/textures to a specific part of a sprite
« on: August 27, 2023, 06:54:08 pm »
Hello, I'm new to SFML and currently working on my first project with the library. I'm working on a really basic fantasy RPG and I'm trying to create a system to detect when the pixels of, (or at this point a rough rectangle around) a weapon collide with another entity, and do damage if a collision is true.

I know how to implement collision detection and I have an animation system working, the problem I have with creating a hitbox is that the "weapon" isn't it's own entity, it's just a part of the sprite texture for the time being.  I've checked the docs looking for a way to attach a separate shape or texture (like a bounding box) to a sprite but I haven't found anything. I've also tried creating an Sf rectangle shape to use as an underlay of sorts but getting it to move with the sprite has been tedious, and I'd assume computationally inefficient.

Could anyone with similar experience provide possible solutions? I'd appreciate it.

Pages: [1]
anything