I want to draw multiple players on the client. It works fine without the foreach rotations, but when i add the foreach rotations it updates both players with eachothers rotation instead of the player who the rotation is meant to be for.
foreach (var kvp in positions)
{
foreach (var kvr in rotations)
{
// draw player
spriteBatch.Draw(texture, kvp.Value, null, Color.White,
kvr.Value, new Vector2(texture.Width / 2, texture.Height / 2), 1f,
SpriteEffects.None, 1f);
}
}
Each player has an unique ID which I store as key inside BOTH dictionaries.
Is there a way that i can combine these dictionaries to achieve the correct result?
Right now Dictonary positions contains (long,Vector2(x,y)) where long is the unique user ID
and the rotations contains (long, float) where long is the same user ID as in positions and float is the rotation.
Edit:
This works fine but doesn’t update the rotation as it’s set.
foreach (var kvp in positions)
{
// draw player
spriteBatch.Draw(texture, kvp.Value, null, Color.White, 1f,
new Vector2(texture.Width / 2, texture.Height / 2), 1f,
SpriteEffects.None, 1f);
}
Is it not as simple as: