O'Reilly logo

XNA 4.0 Game Development by Example Beginner's Guide by Kurt Jaegers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating the Camera class

  1. Add a new class called "Camera" to the Robot Rampage project.
  2. Add the following using directive to the class:
    using Microsoft.Xna.Framework;
    
  3. Modify the declaration of the Camera class to make the class public and static:
    public static class Camera
    
  4. Add declarations to the Camera class:
    #region Declarations
    private static Vector2 position = Vector2.Zero;
    private static Vector2 viewPortSize = Vector2.Zero;
    private static Rectangle worldRectangle = new Rectangle(0, 0, 0, 0);
    #endregion
    
  5. Add properties to the Camera class to access and modify the underlying members:
    #region Properties public static Vector2 Position { get { return position; } set { position = new Vector2( MathHelper.Clamp(value.X, worldRectangle.X, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required