## Introduction Edit

This is the formula sheet for getting the relative positions (left, right, above, below, etc.) to a tile. For example, say you wanted to get the position that is directly to the right of the stairs. This formula sheet will help you out with that.

## Position formulas Edit

Before you begin, here are some variables that will be necessary for understanding this because the formulas will use these variables to explain how to get these relative positions.

```
int pos; (Representation of the original position)
```

```
public static final int WIDTH = 32; (default width of a level)
```

**Right**

The formula for getting any position to the right of an object would be this:

```
pos + (An integer from 1 to anything that doesn't loop the new position to go down).
```

**Left**

The formula for getting any position to the left of an object would be this:

```
pos - (An integer from 1 to anything that doesn't loop the new position to go up).
```

**Down**

The formula for getting any position to the left of an object would be this:

```
pos + WIDTH * (Number of blocks you want it to go down).
```

**Up**

The formula for getting any position to the left of an object would be this:

```
pos - WIDTH * (Number of blocks you want it to go up).
```

**Diagonal**

To get the diagonals of the objects position, you would simply combine a formula for getting the relative vertical position and a formula for a relative horizontal position.

Example (Bottom left diagonal formula):

```
pos + WIDTH - 1.
```

I hope this helps you out while you're modding Pixel Dungeon!