Since a lot of us are into game development, I decided to make this thread a general discussion and questions topic about game development.
I have some questions to begin with,
1. How does one go about only updating those parts of the screen that require it?
In a 2D game, I figured something simple like this would suffice for the drawing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void game_object::update(double time)
{
// ...
if (have_moved)
m_updated = true;
}
void game_object::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
if (m_updated) {
sf::Sprite sprite(m_texture);
target.draw(sprite, states);
}
}
|
as you can see, if the object hasn't moved or changed in some way, then it won't be rendered, but my game loop does something like this:
1 2 3 4
|
window.clear();
for (game_object& object : objects)
window.draw(object);
window.display();
|
Only redrawing objects that have moved doesn't really work because the entire screen gets cleared. But if we didn't clear the screen, then the old renderings would still be present. How can we get rid of everything that shouldn't be on-screen any more, while retaining everything that doesn't need to be redrawn, and redrawing everything that does?
2. In 3D games, how does character customisation work? For example, say the game starts with a basic model and then applies things like facial hair, eye colour, and sliders that modify the size of parts of the model like the height or weight.
Feel free to ask your own questions, answer others', post helpful articles* or just update us on your game development projects.
*
http://gafferongames.com/game-physics/fix-your-timestep/ - Excellent article about writing game loops that run at the same speed regardless of the machine they're running on.