I need advanced collision detection and blitting options in my game as the latter is a 2D game that has trees’ sprites along with the player’s sprite.
I want that every tree sprite gets blitted at a specific position relatively with the player’s coordinates.
Take a look at the images below:
CASE 1 :
So I just want to get the result shown in the previous pictures so that the game works a little more realistic though it’s a 2D one.
As you can see in this image, I want to detect collision only between the player and a part of the tree (that’s in this case the bottom of the trunk). This is because it won’t be realistic at all to detect collision with the entire tree and prevent the player from moving “underneath” it (as it looks in 2d games).
Back to the blitting options, I have an idea in mind which is check for the player’s coordinates and depending on them, blit the tree’s sprite underneath it or above it (respecting the layers system). However, I think that this won’t work or will make the tree’s sprite flicker in case there is more than one player (or another object that can pass beside the tree). So what is a good solution for that ?
Regarding the collision detection, I also got a good idea in my mind that is to make an independent sprite for the part of the tree that I need to check collision with and blit it in a way that it can’t seem to be independent from the entire tree and then check collision between it and player(s). Yet, I guess there is a better implementation using
subsurfaces, no ?
To conclude, I want to implement the 2 features I have explained in a coherent way.