Skip to content

Conversation

@huntekye
Copy link
Contributor

@huntekye huntekye commented Dec 6, 2025

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!

@Hypernoot
Copy link
Member

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.

@huntekye
Copy link
Contributor Author

huntekye commented Dec 6, 2025

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
Copy link
Contributor Author

huntekye commented Dec 7, 2025

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.

Copy link
Contributor

@MatusGuy MatusGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm (code)

Copy link
Member

@swagtoy swagtoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what I'm seeing, but I really wonder if we should move the PlayerBonusType enum into the Player class itself. Have not tested this PR, just a code review

Comment on lines 46 to 50
BonusType type;
PowerUp::Type type;
PlayerBonusType bonus;
SpritePtr sprite;
Flip flip;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, these should be prefixed m_, that way you can avoid doing _type as a function

Comment on lines 27 to 28
physic.set_velocity_y(-325.f);
physic.set_gravity_modifier(0.4f);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I acknowledge that you moved the code into this class, but I think you should put these constants in their own variables, maybe as static constexpr in the class definition itself so others could access them (or just put them locally in the file; up to you)

Comment on lines +22 to +23
/// PowerUp that flings itself upwards
/// can't be collected right away.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: aggressive line width here must've cut this comment in half

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was intentionally two lines, like two sentences?

Comment on lines 39 to 46
enum PlayerBonusType {
BONUS_NONE = 0, /*!< @description No bonus. */
BONUS_GROWUP, /*!< @description Growup (a.k.a. egg) bonus. */
BONUS_FIRE, /*!< @description Fire bonus. */
BONUS_ICE, /*!< @description Ice bonus. */
BONUS_AIR, /*!< @description Air bonus. */
BONUS_EARTH /*!< @description Earth bonus. */
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a part of me wants to say; these should really be in the Player class itself if they are only for the player, so like Player::BonusType

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving it to player.hpp would create more circular include dependencies, which I guess can be dealt with in other ways, but it seems fine where it is? like right now it's being used for the type of bullets that tux fires which is probably fine as long as they don't become more complex.

@huntekye huntekye requested a review from swagtoy December 13, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants