Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.Xna.Framework;
- using BaconEngine.GameComponents;
- namespace BaconEngine
- {
- public class Camera
- {
- #region Fields and Properties
- public Vector2 Position;
- float speed = 8f;
- public float Speed
- {
- get { return speed; }
- set { speed = MathHelper.Clamp(speed, 1.0f, 16.0f); }
- }
- #endregion
- #region Constructors
- public Camera()
- {
- Position = Vector2.Zero;
- }
- public Camera(Vector2 position)
- {
- Position = position;
- }
- #endregion
- #region Methods
- public void LockCamera()
- {
- Position.X = MathHelper.Clamp(Position.X, 0, TileMap.WidthInPixels - Engine.ViewportWidth);
- Position.Y = MathHelper.Clamp(Position.Y, 0, TileMap.HeightInPixels - Engine.ViewportHeight);
- }
- public void LockToSprite(AnimatedSprite sprite)
- {
- Position.X = sprite.Position.X + sprite.Width / 2
- - (Engine.ViewportWidth / 2);
- Position.Y = sprite.Position.Y + sprite.Height / 2
- - (Engine.ViewportHeight / 2);
- }
- #endregion
- }
- }
Add Comment
Please, Sign In to add comment