I am using C# (This question is also valid for similar languages like C++) and I am trying to figure out the fastest and most efficient way to increment. It isn't just one or two increments, in my game, its like 300 increments per second. Like the Frames of every sprite on the screen are incrementing, the speed and positions of my rpg character, the offset of the camera etc. So I am thinking, what way is the most efficient? e.g for incrementing 5 y_pos
on every movement I can do:
1.
Player.YPos += 5;
2.
Player.YPos = Player.YPos + 5;
3.
for (int i = 0; i < 5; i++)
{
Player.YPos++;
}
Which is the most efficient (and fastest)?
See Question&Answers more detail:os