Sunday, November 13, 2016

SNES Super Mario World - How to duplicate blocks to the sides

The Game Resources > SMW wiki has an explanation on how to duplicate blocks from some distance, but it's not satisfactory. Let me provide a better one.

First off, you must throw the projectile upward with null horizontal speed. Remember that Mario doesn't need to have zero speed for this and it's useful to try pressing left+up or right+up.

Every sprite has 4 points of interaction, like draw in the pictures. You must observe the head and the lateral point that touches the block. Drawing the block boundary is also useful.

The solid blocks only push sprites outside every other frame. That means that in odd frames they will push to the right (or left) and in even frames they will push to the opposite side. By the time the projectile gets inside the block, the direction must push the projectile outside and remove the head from its boundary. The lateral push is always 4 pixels wide.

Let's see each step of a duplication away:

click to increase the pictures

The sprite starts with vertical speed -112 and it increases +3 each frame.
Observe that the head is just below the boundary, but not touching it. In this case, the vertical position is 334.0 and the speed is -97. Using the SMW arithmetic, we can calculate the next would-be position:
334.0 - 97 = 334.0 - (6*16 + 1) = 334.0 - 6.0 - 0.1 = 328.0 - 0.1 = 327.F

The projectile goes outside and the duplication occurs:

Let's see what happens in the middle of the frame.
The sprite goes up and the lateral points touch the boundary:
As the right lateral point is inside and the block is pushin to the left, then the sprite goes to the left 4 pixels. If the green area below were to the right, the block wouldn't change its horizontal position. If the head were much to the right, the shift to the left wouldn't be enough to escape the boundary. In this case, the duplication doesn't occur, but the block isn't activated!
Duplication to the right is very similar and the presence of another block in the vicinity doesn't matter.

1) The setup consists in positioning the projectile in a good horizontal position, good vertical position and good vertical subpixel. The closer to the block, the wider is the number of possible initial positions. You should be able to predict the oscillation of the block too and always check if the sprite is not moving to the left/right.

2) the majority of handheld sprites have the same offsets and dimensions. However, it might be the case that the vertical distance between head and laterals is not 7 pixels. In this case, the minimal speed required is not -97.

3) the emulator used was lsnes. The Lua script used to display the helpful info is my smw-tas.

No comments:

Post a Comment