summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2019-02-16 16:33:11 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2019-02-16 16:33:11 -0500
commitd19b13e4c22280ba8e4b394a89e9daf723729157 (patch)
tree826260b673f99e59b6f9f2c8fa3dc46becef131e
parentece716c9cbc625ac32099a1b11293909cb8bf7f1 (diff)
Editing
-rw-r--r--Sideways-stairs-with-diagonal-movement.md41
1 files changed, 24 insertions, 17 deletions
diff --git a/Sideways-stairs-with-diagonal-movement.md b/Sideways-stairs-with-diagonal-movement.md
index 49ad1ca..b16fd87 100644
--- a/Sideways-stairs-with-diagonal-movement.md
+++ b/Sideways-stairs-with-diagonal-movement.md
@@ -2,8 +2,6 @@ All the stairs in Gen 1 and 2 only go upwards. Gen 3 had a few that go downwards
(The code for this feature was adapted from [Pokémon Brass](https://github.com/WasabiRaptor/Pokemon-Brass/).)
-[Here](https://github.com/Rangi42/pokecrystal/commit/8095894b01b1b95d1cb6ab325ac84a825f5f9a90) are all the changes needed to implement diagonal stairs, applied to a copy of pokecrystal. You can `clone` [Rangi42/pokecrystal](https://github.com/Rangi42/pokecrystal/tree/diagonal-stairs) and `checkout` the `diagonal-stairs` branch to test it for yourself.
-
## Contents
@@ -34,9 +32,12 @@ Edit [constants/collision_constants.asm](../blob/master/constants/collision_cons
HI_NYBBLE_UNUSED_C0 EQU $c0
+HI_NYBBLE_DIAGONAL_STAIRS EQU $d0
```
-Diagonal stairs take up two collision constants, one for right and one for left, as there would be no *sideways* stairs that go up or down. And note the HI_NYBBLE being $d0, these stairs are implemented much like jump ledges and are triggered in a similar way, jump ledges all have a HI_NYBBLE being $b grouping them together so we're having our stairs have it be $d to group them together.
-And edit [data/collision_permissions.asm](../blob/master/data/collision_permissions.asm):
+Diagonal stairs need two collision constants, one for right and one for left, as there would be no *sideways* stairs that go up or down.
+
+Notice the use of `HI_NYBBLE_DIAGONAL_STAIRS`. Sideways stairs are implemented much like jump ledges, and are triggered in a similar way; jump ledges all have a `HI_NYBBLE_LEDGES` grouping them together, so we're doing the same for sideways stairs.
+
+Edit [data/collision_permissions.asm](../blob/master/data/collision_permissions.asm):
```diff
TileCollisionTable::
@@ -63,9 +64,10 @@ Edit [constants/map_object_constants.asm](../blob/master/constants/map_object_co
+ const STEP_TYPE_NPC_DIAGONAL_STAIRS
+ const STEP_TYPE_PLAYER_DIAGONAL_STAIRS
```
-The player is controlled by, well, the player and has the camera follow them, so most types of steps have to account for it being an NPC or the player and act accordingly
-Then edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map_objects.asm):
+The player is controlled by, well, the player, and has the camera follow them, so most types of steps have to account for it being an NPC or the player and act accordingly.
+
+Edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map_objects.asm):
```diff
StepTypesJumptable:
@@ -79,6 +81,7 @@ Then edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map
```diff
+NPCDiagonalStairs:
++ ; TODO
+ ret
+
+PlayerDiagonalStairs:
@@ -164,13 +167,13 @@ Then edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map
+ ret
```
-This is where the step actually happens, the object never actually moves diagonally but instead moves horizontally in the direction they entered from, and then vertically once.
+This is where the step actually happens. The object never actually moves diagonally, but instead moves horizontally in the direction they entered from, and then vertically once.
-While moving horizontally the Y offset of the sprite is moved up or down depending on if the object is in the top half or bottom half of the mettatile/block where they triggered the step, this gives the illusion of moving diagonally.
+While moving horizontally, the Y offset of the sprite is moved up or down depending on if the object is in the top half or bottom half of the mettatile/block where they triggered the step. This gives the illusion of moving diagonally.
-While moving vertically the object is then met back up with its sprite, removing the offset smoothly by doing the opposite to the offset as the object is now moving vertically towards it, during this time the object technically should not be moving while technically it is, so we set its action to standing so it does not play the step animation while waiting for itself to catch up, or in the player's case, for the camera to catch up.
+While moving vertically, the object is then met back up with its sprite, removing the offset smoothly by doing the opposite to the offset as the object is now moving vertically towards it. During this time the object technically should not be moving while technically it is, so we set its action to standing so it does not play the step animation while waiting for itself to catch up, or in the player's case, for the camera to catch up.
-the movement of going horizontal twice and vertical once might be noticeable by the player due to the camera movement not being "diagonal" like the sprite's and by all accounts the camera in pokecrystal can move diagonally, and I had worked to try and make it do so, but this causes de-sync with the screen and the player object so that it is no longer centered, and will load tiles and blocks incorrectly on the edge of the screen that would normally be outside the visible area due to this de-sync
+The movement of going horizontal twice and vertical once might be noticeable by the player due to the camera movement not being "diagonal" like the sprite's. Theoretically the camera in pokecrystal can move diagonally, and I had worked to try and make it do so, but this causes de-sync with the screen and the player object so that it is no longer centered, and will load tiles and blocks incorrectly on the edge of the screen that would normally be outside the visible area.
## 3. Add movement commands for diagonal steps
@@ -263,7 +266,7 @@ Then edit [engine/overworld/movement.asm](../blob/master/engine/overworld/moveme
+ ret
```
-Diagonal stairs albeit being only in the two directions right and left, need their macros and pointers placed with the other directional step types to be triggered correctly, and it is here where the game determines if it should be making the player or an NPC take the step
+Even though diagonal stairs only go in two directions, right and left, they need their macros and pointers placed with the other directional step types to be triggered correctly. It is here where the game determines if it should be making the player or an NPC take the step.
## 4. Use the diagonal step movement for the sideways stair collision type
@@ -433,7 +436,7 @@ Then edit [engine/overworld/player_movement.asm](../blob/master/engine/overworld
+ stairs_step RIGHT
```
-Now for actually triggering the step, firstly is obviously just having the game try it among the other types of steps and since it is extremely similar to the jump step in essence it is triggered in much the same way, it checks for the high nybble to see if it is the one the stair steps have, and if it does then it checks if the player is facing the direction matching the stairs to go up or down them if they do it loads the step and then executes everything that was coded above
+Now for actually triggering the step. Firstly is obviously just having the game try it among the other types of steps, and since it is extremely similar to the jump step in essence it is triggered in much the same way. It checks for the high nybble to see if it is the one the stair steps have, and if it does then it checks if the player is facing the direction matching the stairs to go up or down. If they do, it loads the step and then executes everything that was coded above.
## 5. Add sideways stairs to a map
@@ -456,18 +459,22 @@ Now test it out!
![Screenshot](screenshots/sideways-stairs.png)
-Have you gone and looked at the tutorials on how to edit blocks and tilesets? great! Now to explain how to use COLL_DIAGONAL_STAIRS_RIGHT and COLL_DIAGONAL_STAIRS_LEFT in a map properly, when these collision constants are placed on a tile with a WALL collision adjacent in the direction they indicate, they will trigger the diagonal stairs step coded and defined above, you will note that these do not have any definition for going up or down? well thats because it is decided by which half of the mettatile/block you place the collision on.
+Have you gone and looked at the tutorials on how to edit blocks and tilesets? Great! Now to explain how to use `DIAGONAL_STAIRS_RIGHT` and `DIAGONAL_STAIRS_LEFT` in a map properly. When these collision constants are placed on a tile with a `WALL` collision adjacent in the direction they indicate, they will trigger the diagonal stairs step coded and defined above. You will note that these do not have any definition for going up or down? Well that's because it is decided by which half of the mettatile/block you place the collision on.
-If COLL_DIAGONAL_STAIRS_RIGHT is placed in the top half of a block and the step is triggered then the player will move right two steps and then down once, if its in the bottom half it will move the player right two steps right and then up one, the same is true for the left direction.
+If `DIAGONAL_STAIRS_RIGHT` is placed in the top half of a block and the step is triggered, then the player will move right two steps and then down one. If it's in the bottom half, it will move the player right two steps and then up one. The left direction works similarly.
+
+To have a full set of stairs that you can walk up and down both ways, it requires four blocks with collision set accordingly: two blocks per direction of stairs, since the entire "structure" of sorts requires the space of three walkable tiles to function.
-To have a full set of stairs one can walk up and down both ways requires four blocks with collision set accordingly two blocks per direction of stairs since the entire "structure" of sorts requires the space of three walkable tiles to function
```
tilecoll FLOOR, FLOOR, FLOOR, DIAGONAL_STAIRS_RIGHT
tilecoll WALL, DIAGONAL_STAIRS_LEFT, WALL, FLOOR
```
-this would be needed for a set of stairs going up to the right
+
+This would be needed for a set of stairs going up to the right.
+
```
tilecoll DIAGONAL_STAIRS_RIGHT, WALL, FLOOR, WALL
tilecoll FLOOR, FLOOR, DIAGONAL_STAIRS_LEFT, FLOOR
```
-this would be needed for a set of stairs going up to the left \ No newline at end of file
+
+This would be needed for a set of stairs going up to the left.