Download in video's description
Originally posted by Changelog
Changes:
- Mario now bounces off walls, ground and ceiling when going fast.
- Now compatible with slopes and interactable Layer 2
- Fixes showing glitched graphics upon grabbing the balloon item
- Changed its sprite slot when it inflates Mario
- Added an option to mute some SFX when Mario is inflated
- Added a debug option to show a small target.
- Added an option to stop fixing the camera on Mario when he's inflated
- Added an option to carry sprites when Mario is inflated
- Added missing palette file.
- Mario now bounces off walls, ground and ceiling when going fast.
- Now compatible with slopes and interactable Layer 2
- Fixes showing glitched graphics upon grabbing the balloon item
- Changed its sprite slot when it inflates Mario
- Added an option to mute some SFX when Mario is inflated
- Added a debug option to show a small target.
- Added an option to stop fixing the camera on Mario when he's inflated
- Added an option to carry sprites when Mario is inflated
- Added missing palette file.
Code
;################################################################################################## ;# Super Mario Maker 2's P-Balloon ;# by lx5 ;# ;# A P-Balloon powerup inspired by Super Mario Maker 2's variant in its Super Mario World style. ;# It recreates the controls and behavior of the SMM2's one and it's contained in a single sprite. ;# ;# NOTES: ;# - THIS SPRITE ONLY WORKS ON SA-1. ;# - It fails to detect Layer 3 smashers. ;# - It doesn't work with solid sprites, however, it does work with platforms passable from below. ;# - Mario is NOT able to carry the powerup to another level or sublevel. The sprite will despawn ;# the very moment Mario is not under the player's control. ;# - The sprite makes use of SA-1's Background Mode in order to rotate its graphics and uses ;# 4 Character Conversion DMA slots. Probably no one will have issues with this. ;# - If you want to create graphics for the Inflated Mario, you have to create an image and rip ;# each frame separately with SNESGFX with the 4bpp Linear option selected.
If some of you are curious about how this powerup works internally, I have a gif for you:
As the image shows, there's a target that the sprite follows every frame, by using %CircleX() and %CircleY(), I managed to get a target that rotates around the sprite depending on the controller input. That target position is used in conjunction with the %Aiming() routine to calculate X and Y speeds. That allowed me to not reinvent the wheel to calculate speeds depending on the angle and gave me the oportunity to easily give it some inertia/friction when changing directions and be similar-ish to how it works in SMM2.
When an input to change direction is received, the sprite determines what's the shortest way to turn around to reach its location as soon as possible, just like in SMM2. I was making something overly complicated about something that could be done in a few steps.
And finally, slopes and layer 2 support was added in a wacky way. Turns out that setting the sprite's position to Mario's position before updating the sprite's positions gives me proper support to these things without making extra long code (I thought about adding slope's code into this thing...).
🎈