> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball/camera/maximumx.md).

# MaximumX

### Introduction

The MaximumX, MaximumY, MinimumX, and MinimumY properties can set the minimum and maximum X and Y positional values for a given Camera. These properties can be used to create boundaries beyond which the camera cannot move. These are often used in games to keep the camera viewing the playable area and keep areas beyond the playable bounds from being viewed.

### Note about Cameras and Entities

If you have a Camera which is part of an Entity then the Camera will be attached to that Entity (by default). The minimum and maximum values will prevent the Camera from moving behond the values you specify, but it will not prevent the parent Entity from moving beyond the bounds. In this situation it is advised to use your own custom min and max implementation.

### Code Sample

The following code allows the user to move the camera with the arrow keys on the keyboard, but bounds the position of the Camera to the edges of the [AxisAlignedRectangle](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php) created in the Initialize method.

Add the following to your Screen's CustomInitialize:

```
 AxisAlignedRectangle rectangle = ShapeManager.AddAxisAlignedRectangle();
 rectangle.ScaleX = 500;
 rectangle.ScaleY = 500;

 Camera.Main.MaximumX = rectangle.X + rectangle.Width/2.0f;
 Camera.Main.MaximumY = rectangle.Y + rectangle.Height/2.0f;
 Camera.Main.MinimumX = rectangle.X - rectangle.Width/2.0f;
 Camera.Main.MinimumY = rectangle.Y - rectangle.Height/2.0f;
```

Add the following to Update

```
InputManager.Keyboard.ControlPositionedObject(Camera.Main, 100);
```

![MinimumMaximumCameraValues.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-33752d92a4a8a28dd20754c6ba8b924fe537c1e5%2Fmigrated_media-MinimumMaximumCameraValues.png?alt=media)

### Removing Minimum and Maximum Values

See [FlatRedBall.Camera.ClearMinimumsAndMaximums](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/api/flatredball/camera/maximumx.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
