Back on the Super Mario Bros. game to add some new, much needed features.
This time around, I am focused on giving Mario the ability to power up. If you are not familiar with the game, once the super hero digests a magic mushroom, he either become Super Mario, or Fire Mario, with greater power potential.
I’m running into bit of a problem with the transformation however.
Currently, the boundary box, or hitbox that surrounds Mario isn’t representative of his actual dimensions.
/// Current power types for Mario.
enum MarioType {
mario,
superMario,
}
This means the hitbox can’t properly detect Mario’s collisions with the ground when he’s of a greater size.
/// Update form type and size of Mario.
void _transform({required bool upgrade}) {
if (upgrade) {
switch (_marioType) {
case MarioType.mario:
size = Vector2 (Globals.tileSize, Globals.tileSize * 2);
_marioType = MarioType.superMario;
break;
case MarioType.superMario:
// TODO: Transform to fiery mario.
break;
}
} else {
switch (_marioType) {
case MarioType.mario:
// TODO: Die.
break;
case MarioType.superMario:
size = Vector2(Globals.tileSize, Globals.tileSize);
_marioType = MarioType.mario;
break;
}
}
}
Some serious research is required…