I'm proud to present my first library: SFGE. It's been under development for a little over 2 weeks now. It's built on top of the sfml library.
Features:
- Event System
- Collision detection and response (AABB or convex shapes)
- Logging
- StateManagement
- Animated Sprites
- ResourceManager
- Menu System
Didn't have time to look into it right now, how do you handle collision response? That one's still giving me headaches (less the physical reactions than the issue of objects of different types causing different reactions, like damage, healing, starting swimming etc - I couldn't think of a good solution to that so far).
Well, for the collision response it gives the MTV (Minimum Translation Vector). It doesn't do physics, but provides you with enough information to resolve the collision. Every object that can be added to a CollisionDetector needs to derive from Collidable. Collidable has a virtual method which returns the shape and holds a std::string member variable which is returned via std::string getName();
It also has a virtual method onCollision(Collidable* obj, sf::Vector2f mtv) which can be reimplemented if you want to actually do something with the collision.
You can quickly check for the type of object you've collided with, and if necessary you can cast it to the appropriate type:
So if I understand this right I'd implement a class Node to which other nodes can be added and removed. What other functionality should I incorporate in this class?
There's no true definition as to what a scene graph is and how is should be implemented as it depends entirely on the project. In your case, however, I would suggest incorporating these features:
- Draw the sprite/mesh (the obvious one)
- Draw particles and/or light, ect
- Play sounds
- Update physics
- Update the frame of an animation or play the animation
As I said, there's no true definition as to how a scene graph is implemented.
Does that look OK to you?
The user should not forget to call the updateChildren and drawChildren method when they override the function though...
PS: Sorry for the messed up spacing. Notepad++ didn't convert tabs to spaces, I noticed -.-
PPS: We can later derive a PhysicsNode and more specific nodes