MCPcopy Create free account
hub / github.com/EasyRPG/Player / SetAttributesTransitions

Method SetAttributesTransitions

src/transition.cpp:122–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void Transition::SetAttributesTransitions() {
123 int w, h, beg_i, mid_i, end_i, length;
124
125 zoom_position = std::vector<int>(2);
126 random_blocks = std::vector<uint32_t>(Player::screen_width * Player::screen_height / (size_random_blocks * size_random_blocks));
127 for (uint32_t i = 0; i < random_blocks.size(); i++) {
128 random_blocks[i] = i;
129 }
130
131 switch (transition_type) {
132 case TransitionRandomBlocks:
133 random_block_transition = Bitmap::Create(Player::screen_width, Player::screen_height, true);
134 current_blocks_print = 0;
135 std::shuffle(random_blocks.begin(), random_blocks.end(), Rand::GetRNG());
136 break;
137 case TransitionRandomBlocksDown:
138 case TransitionRandomBlocksUp:
139 random_block_transition = Bitmap::Create(Player::screen_width, Player::screen_height, true);
140 current_blocks_print = 0;
141 if (transition_type == TransitionRandomBlocksUp) { std::reverse(random_blocks.begin(), random_blocks.end()); }
142
143 w = Player::screen_width / 4;
144 h = Player::screen_height / 4;
145 length = 10;
146 for (int i = 0; i < h - 1; i++) {
147 end_i = (i < length ? 2 * i + 1 : i <= h - length ? i + length : (i + h) / 2) * w;
148 std::shuffle(random_blocks.begin() + i * w, random_blocks.begin() + end_i, Rand::GetRNG());
149
150 beg_i = i * w + (i % 2 == 0 ? 0 : 2);
151 mid_i = i * w + (i % 2 == 0 ? 1 : 3) + (i > h * 2 / 3 ? 3 : 0);
152 if (transition_type == TransitionRandomBlocksDown) {
153 std::partial_sort(random_blocks.begin() + beg_i, random_blocks.begin() + mid_i, random_blocks.begin() + end_i);
154 }
155 else { std::partial_sort(random_blocks.begin() + beg_i, random_blocks.begin() + mid_i, random_blocks.begin() + end_i, std::greater<uint32_t>()); }
156 }
157 break;
158 case TransitionZoomIn:
159 case TransitionZoomOut:
160 if (scene != nullptr && scene->type == Scene::Map) {
161 auto map = static_cast<Scene_Map*>(scene);
162
163 zoom_position[0] = std::max(0, std::min(Main_Data::game_player->GetScreenX() + map->spriteset->GetRenderOx(), (int)Player::screen_width));
164 zoom_position[1] = std::max(0, std::min(Main_Data::game_player->GetScreenY() - 8 + map->spriteset->GetRenderOy(), (int)Player::screen_height));
165 }
166 else {
167 zoom_position[0] = Player::screen_width / 2;
168 zoom_position[1] = Player::screen_height / 2;
169 }
170 break;
171 default:
172 // do nothing, keep the compiler happy
173 break;
174 }
175}
176
177void Transition::Draw(Bitmap& dst) {
178 if (!IsActive())

Callers

nothing calls this directly

Calls 9

maxFunction · 0.85
minFunction · 0.85
GetScreenXMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetRenderOxMethod · 0.45
GetScreenYMethod · 0.45
GetRenderOyMethod · 0.45

Tested by

no test coverage detected