summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sideways-stairs-with-diagonal-movement.md31
1 files changed, 26 insertions, 5 deletions
diff --git a/Sideways-stairs-with-diagonal-movement.md b/Sideways-stairs-with-diagonal-movement.md
index ab9dafd..49ad1ca 100644
--- a/Sideways-stairs-with-diagonal-movement.md
+++ b/Sideways-stairs-with-diagonal-movement.md
@@ -34,7 +34,7 @@ Edit [constants/collision_constants.asm](../blob/master/constants/collision_cons
HI_NYBBLE_UNUSED_C0 EQU $c0
+HI_NYBBLE_DIAGONAL_STAIRS EQU $d0
```
-Diagonal stairs
+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):
@@ -63,6 +63,7 @@ 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):
@@ -163,7 +164,13 @@ Then edit [engine/overworld/map_objects.asm](../blob/master/engine/overworld/map
+ ret
```
-TODO: Explain changes.
+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 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
## 3. Add movement commands for diagonal steps
@@ -256,7 +263,7 @@ Then edit [engine/overworld/movement.asm](../blob/master/engine/overworld/moveme
+ ret
```
-TODO: Explain changes.
+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
## 4. Use the diagonal step movement for the sideways stair collision type
@@ -426,7 +433,7 @@ Then edit [engine/overworld/player_movement.asm](../blob/master/engine/overworld
+ stairs_step RIGHT
```
-TODO: Explain changes.
+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
## 5. Add sideways stairs to a map
@@ -449,4 +456,18 @@ Now test it out!
![Screenshot](screenshots/sideways-stairs.png)
-TODO: Explain how to use `COLL_DIAGONAL_STAIRS_RIGHT` and `COLL_DIAGONAL_STAIRS_LEFT`.
+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.
+
+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.
+
+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
+```
+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