supertux icon indicating copy to clipboard operation
supertux copied to clipboard

Consistent semantics for powerups and bonuses

Open huntekye opened this issue 2 weeks ago • 3 comments

Powerups, bonusblocks, and friends now use PowerUp::Type where possible.

BonusType is renamed to PlayerBonusType to clarify its usage, i.e., to enumerate Tux's (or other future players?) possible states.

Function signatures are changed from ints to the appropriate enum type where possible.

PocketPowerUp is moved from player_status to its own file in src/object to eliminate circular include dependencies between powerup.hpp and player_status.hpp.

Hopefully this will make working and adding new powerups easier in the future.

Let me know if you see any mistakes or have any suggestions!

huntekye avatar Dec 06 '25 17:12 huntekye

Maybe instead of PlayerBonusType, we could have just PlayerType and the values could be something like SMALL_TUX, BIG_TUX, FIRE_TUX, etc.. Just keep in mind that the legacy names should be still usable from the squirrel interface, so it doesn't break old levels. Just an idea.

Hypernoot avatar Dec 06 '25 20:12 Hypernoot

Yeah I think I would prefer names like FIRE_TUX or ICE_TUX instead of BONUS_FIRE etc., but at the same time if backwards compatibility means that they are no better than aliases for the current versions, it might just make things more confusing rather than less. And it would require touching a lot of files. But at the same time I can see where it could be worth it to prevent things like PlayerBonusType being used to distinguish between fire bullets and ice bullets (should maybe be changed too).

Oh and between PlayerBonusType and PlayerType I think I went with PlayerBonusType because in principle the Player and PlayerStatus have a lot of other attributes, but this one is specific to having bonuses... but idk these are small things, if other people have a strong preference then I have no problem changing things.

huntekye avatar Dec 06 '25 21:12 huntekye

Actually, thinking about it a little more, we could take this a step farther to gain some interesting new functionality. If we add a PlayerStatus::active_powerup attribute, this could reuse the powerup enum directly instead of/in addition to PlayerBonusType. This could be useful in the case of the retro/reskined powerups, allowing for e.g. a coffee sprite in the item pocket, or coffee bullets with powerup type COFFEE but bonus type BONUS_FIRE.

Or it's probably fine as-is; I think the coffee bullet idea has at least convinced me that PlayerBonusType is being used correctly in the places it's still left.

huntekye avatar Dec 07 '25 08:12 huntekye