Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Update(GameTime theGameTime)
- {
- Sprite previous = null;
- foreach (var sprite in body)
- {
- if (previous != null)
- {
- if (previous.position != sprite.position)
- {
- //float x = sprite.position.X - previous.position.X;
- //float y = sprite.position.Y - previous.position.Y;
- Vector2 tempDirection = sprite.position - previous.position;
- tempDirection.Normalize();
- Vector2 tempSpeed = new Vector2(tempDirection.X != 0 ? SNAKE_SPEED : 0, tempDirection.Y != 0 ? SNAKE_SPEED : 0);
- sprite.Update(theGameTime, tempSpeed, tempDirection);
- //sprite.Update(theGameTime, tempDirection, tempDirection);
- }
- }
- else
- {
- KeyboardState currentKeyboardState = Keyboard.GetState();
- UpdateMovement(currentKeyboardState);
- previousKeyboardState = currentKeyboardState;
- sprite.Update(theGameTime, speed, direction);
- }
- /*if (previous == null)
- {
- KeyboardState currentKeyboardState = Keyboard.GetState();
- UpdateMovement(currentKeyboardState);
- previousKeyboardState = currentKeyboardState;
- sprite.Update(theGameTime, speed, direction);
- }
- else
- {
- UpdateMovement(previousKeyboardState);
- sprite.Update(theGameTime, speed, direction);
- }*/
- previous = sprite;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment