From c3572c62a903c3dff4a1d0e4dbaf485e2fd23be1 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 9 Jun 2022 13:27:13 +0200 Subject: [PATCH] [Maintenance] [th01] Boss entities: Add a static sprite size wrapper template Not too useful for Elis since she's already got the form system, but it will save a bit of boilerplate code for Kikuri. Part of P0198, funded by Lmocinemod and Ember2528. --- th01/main/boss/entity_a.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/th01/main/boss/entity_a.hpp b/th01/main/boss/entity_a.hpp index 3e06541d..5ea91af9 100644 --- a/th01/main/boss/entity_a.hpp +++ b/th01/main/boss/entity_a.hpp @@ -253,6 +253,22 @@ public: /// ------------------- }; +// Despite CBossEntity's own width and height fields, ZUN still likes to +// statically hardcode the intended sprite sizes when calculating offsets +// within a .BOS sprite. Since bosses either declare their own instances or +// #define more readable names for each instance of [boss_entities], we might +// as well use the opportunity to lift up these static sizes into the type +// system, and avoid the need for per-boss boilerplate coordinate functions. +template struct CBossEntitySized : public CBossEntity { + screen_x_t cur_center_x(void) const { + return (cur_left + (W / 2)); + } + + screen_x_t cur_center_y(void) const { + return (cur_top + (H / 2)); + } +} + // Frees all images in the given [slot]. void bos_entity_free(int slot);