Rev 21 | Rev 25 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 21 | Rev 24 | ||
---|---|---|---|
Line 128... | Line 128... | ||
128 | boardslot_t *boardslot; |
128 | boardslot_t *boardslot; |
129 | boardmove_t *currentmove; |
129 | boardmove_t *currentmove; |
130 | player_t *local_player; |
130 | player_t *local_player; |
131 | player_t *network_player; |
131 | player_t *network_player; |
132 | player_t *current_player; |
132 | player_t *current_player; |
- | 133 | player_t *opposite_player; |
|
133 | wchar_t *history_text; // mallocated |
134 | wchar_t *history_text; // mallocated |
134 | int historytext_size; |
135 | int historytext_size; |
135 | unsigned char takenpart_type; |
136 | unsigned char takenpart_type; |
136 | int movement_direction; |
137 | int movement_direction; |
137 | int line; |
138 | int line; |
Line 156... | Line 157... | ||
156 | int movement_diffco; |
157 | int movement_diffco; |
157 | int movement_diffli; |
158 | int movement_diffli; |
158 | float movement_maxheight; |
159 | float movement_maxheight; |
159 | float movement_ratio; |
160 | float movement_ratio; |
160 | 161 | ||
161 | // get the current player (we'll need it) and see if we're online |
162 | // get the current player (we'll need it), its opponent and see if we're online |
162 | current_player = Player_GetCurrent (); |
163 | current_player = Player_GetCurrent (); |
- | 164 | opposite_player = Player_GetOpposite (); |
|
163 | network_player = Player_FindByType (PLAYER_INTERNET); |
165 | network_player = Player_FindByType (PLAYER_INTERNET); |
- | 166 | ||
- | 167 | // get the current move |
|
- | 168 | currentmove = &board->moves[board->viewed_move]; // quick access to current move |
|
164 | 169 | ||
165 | // fetch the background sprite from the theme |
170 | // fetch the background sprite from the theme |
166 | if (want_custombackground) |
171 | if (want_custombackground) |
167 | scene->background_spriteindex = custombg.sprite_index; // use the custom background if specified |
172 | scene->background_spriteindex = custombg.sprite_index; // use the custom background if specified |
168 | else |
173 | else |
Line 189... | Line 194... | ||
189 | // draw the grid numbers if we want them |
194 | // draw the grid numbers if we want them |
190 | if (want_grid) |
195 | if (want_grid) |
191 | Scene_AddTile (scene, theme->grid_texture, 30.0f, 0.0f, 0.0f, 0.01f, 0.0f); |
196 | Scene_AddTile (scene, theme->grid_texture, 30.0f, 0.0f, 0.0f, 0.01f, 0.0f); |
192 | 197 | ||
193 | //////////////////////////////////////////////////////////////////////////////////////////////// |
198 | //////////////////////////////////////////////////////////////////////////////////////////////// |
194 | // draw the 3D parts that are still in play |
- | |
195 | - | ||
196 | currentmove = &board->moves[board->viewed_move]; // quick access to current move |
- | |
197 | - | ||
198 | // if we want the 3D parts, cycle through all the grid and place them |
- | |
199 | if (!want_flaticons || (current_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
- | |
200 | for (line = 0; line < 8; line++) |
- | |
201 | for (column = 0; column < 8; column++) |
- | |
202 | { |
- | |
203 | boardslot = ¤tmove->slots[line][column]; // quick access to grid slot |
- | |
204 | - | ||
205 | // is there nothing on this grid slot ? |
- | |
206 | if (boardslot->part == PART_NONE) |
- | |
207 | continue; // then don't draw anything on it |
- | |
208 | - | ||
209 | // has a movement happened yet AND does it land on this slot ? |
- | |
210 | if ((board->viewed_move > 0) |
- | |
211 | && (line == currentmove->target[0]) && (column == currentmove->target[1])) |
- | |
212 | { |
- | |
213 | // do we want animations AND is it still time to play the animation ? |
- | |
214 | if (options.want_animations && (animation_endtime > current_time)) |
- | |
215 | { |
- | |
216 | // get the source and target X and Y positions |
- | |
217 | source_x = 17.5f - (7 - currentmove->source[1]) * 5.0f; |
- | |
218 | source_y = 17.5f - currentmove->source[0] * 5.0f; |
- | |
219 | target_x = 17.5f - (7 - currentmove->target[1]) * 5.0f; |
- | |
220 | target_y = 17.5f - currentmove->target[0] * 5.0f; |
- | |
221 | - | ||
222 | // compute the movement completion ratio between 0 and 1 |
- | |
223 | movement_ratio = 1.0f - (animation_endtime - current_time) / ANIMATION_DURATION; |
- | |
224 | - | ||
225 | // compute the current X an Y based on movement timing |
- | |
226 | current_x = source_x + (target_x - source_x) * movement_ratio; |
- | |
227 | current_y = source_y + (target_y - source_y) * movement_ratio; |
- | |
228 | - | ||
229 | // height is a sine positive, max height is proportional to travelled distance |
- | |
230 | movement_diffco = abs (currentmove->target[1] - currentmove->source[1]); |
- | |
231 | movement_diffli = abs (currentmove->target[0] - currentmove->source[0]); |
- | |
232 | movement_maxheight = 0.5f + (float) movement_diffco + (float) movement_diffli; |
- | |
233 | if (currentmove->part == PART_KNIGHT) |
- | |
234 | movement_maxheight *= 2.0f; // knights jump high |
- | |
235 | else if ((currentmove->part == PART_KING) && (movement_diffco == 2)) |
- | |
236 | movement_maxheight *= 5.0f; // kings jump VERY high when castling too |
- | |
237 | else if (movement_maxheight > 5.0f) |
- | |
238 | movement_maxheight = 5.0f; // all other parts just hover above the ground |
- | |
239 | current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight; |
- | |
240 | - | ||
241 | // make this part move realistically |
- | |
242 | Scene_AddPart (scene, boardslot->part, boardslot->color, current_x, current_y, current_z, 0.0f, (boardslot->color == COLOR_BLACK ? -1 : 1) * min (current_z * 3.0f, 10.0f)); |
- | |
243 | } |
- | |
244 | else |
- | |
245 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
- | |
246 | - | ||
247 | // is it time to play a move sound ? |
- | |
248 | if ((sound_playtime != 0) && (sound_playtime < current_time)) |
- | |
249 | { |
- | |
250 | // is the current player in check ? (to play the right sound) |
- | |
251 | // read as: was the last move an opponent's move AND did it put us to check ? |
- | |
252 | if (currentmove->is_check) |
- | |
253 | { |
- | |
254 | // is it a checkmate or a normal check ? (checkmate == check + stalemate) |
- | |
255 | if (currentmove->is_stalemate) |
- | |
256 | Audio_PlaySound (board->players[currentmove->color].type == PLAYER_HUMAN ? SOUNDTYPE_VICTORY : SOUNDTYPE_DEFEAT); // if so, play endgame sound |
- | |
257 | else |
- | |
258 | Audio_PlaySound (SOUNDTYPE_CHECK); // else play the check sound |
- | |
259 | } |
- | |
260 | else |
- | |
261 | { |
- | |
262 | // is it a stalemate, a capture or a normal move ? |
- | |
263 | if (currentmove->is_stalemate) |
- | |
264 | Audio_PlaySound (SOUNDTYPE_DEFEAT); // on stalemate, play defeat sound |
- | |
265 | else if (currentmove->has_captured) |
- | |
266 | Audio_PlaySound (SOUNDTYPE_PIECETAKEN); // on capture, play the capture sound |
- | |
267 | else |
- | |
268 | Audio_PlaySound (SOUNDTYPE_MOVE); // else play the normal move sound |
- | |
269 | } |
- | |
270 | - | ||
271 | sound_playtime = 0; // mark this animation as completed and sound played |
- | |
272 | } |
- | |
273 | } |
- | |
274 | - | ||
275 | // else has a movement happened yet AND is this movement a castle AND is this the concerned tower ? |
- | |
276 | else if ((board->viewed_move > 0) |
- | |
277 | && (towupper (currentmove->pgntext[0]) == L'O') // either O-O-O or O-O |
- | |
278 | && (line == (currentmove->color == COLOR_WHITE ? 0 : 7)) && (column == (currentmove->target[1] == 2 ? 3 : 5))) |
- | |
279 | { |
- | |
280 | // do we want animations AND is it still time to play the animation ? (castling rooks move faster) |
- | |
281 | if (options.want_animations && (animation_endtime - (0.5f * ANIMATION_DURATION) > current_time)) |
- | |
282 | { |
- | |
283 | // get the source and target X and Y positions |
- | |
284 | source_x = 17.5f - (7 - (currentmove->target[1] == 2 ? 0 : 7)) * 5.0f; // if king moves left, then rook starts on column a, else it starts on column h |
- | |
285 | source_y = 17.5f - line * 5.0f; |
- | |
286 | target_x = 17.5f - (7 - column) * 5.0f; |
- | |
287 | target_y = 17.5f - line * 5.0f; |
- | |
288 | - | ||
289 | // compute the movement completion ratio between 0 and 1 (castling rooks move faster) |
- | |
290 | movement_ratio = min (1.0f, 1.0f - (animation_endtime - (0.5f * ANIMATION_DURATION) - current_time) / (0.5f * ANIMATION_DURATION)); |
- | |
291 | - | ||
292 | // compute the current X an Y based on movement timing |
- | |
293 | current_x = source_x + (target_x - source_x) * movement_ratio; |
- | |
294 | current_y = source_y + (target_y - source_y) * movement_ratio; |
- | |
295 | - | ||
296 | // height is a sine positive, max height is proportional to travelled distance |
- | |
297 | movement_maxheight = 1.0f; // castling rook will barely hover above the ground |
- | |
298 | current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight; |
- | |
299 | - | ||
300 | // make this part move realistically |
- | |
301 | Scene_AddPart (scene, boardslot->part, boardslot->color, current_x, current_y, current_z, 0.0f, (boardslot->color == COLOR_BLACK ? -1 : 1) * min (current_z * 3.0f, 10.0f)); |
- | |
302 | - | ||
303 | if (movement_ratio < 0.9f) |
- | |
304 | rooksound_played = false; // if the rook is still moving, reset the "sound played" flag |
- | |
305 | else if (!rooksound_played) |
- | |
306 | { |
- | |
307 | Audio_PlaySound (SOUNDTYPE_MOVE); // when the rook has landed, play a move sound |
- | |
308 | rooksound_played = true; // remember this is no longer to be done |
- | |
309 | } |
- | |
310 | } |
- | |
311 | else |
- | |
312 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
- | |
313 | } |
- | |
314 | - | ||
315 | // else this part is static, so draw a static object |
- | |
316 | else |
- | |
317 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
- | |
318 | } |
- | |
319 | - | ||
320 | //////////////////////////////////////////////////////////////////////////////////////////////// |
- | |
321 | // |
199 | // recompute the slot textures (only in play mode when we render the real board) |
322 | 200 | ||
323 | // erase all the slot flags |
201 | // erase all the slot flags |
324 | for (line = 0; line < 8; line++) |
202 | for (line = 0; line < 8; line++) |
325 | for (column = 0; column < 8; column++) |
203 | for (column = 0; column < 8; column++) |
326 | currentmove->slots[line][column].flags = FLAG_NONE; // because we will recompute them |
204 | currentmove->slots[line][column].flags = FLAG_NONE; // because we will recompute them |
Line 865... | Line 743... | ||
865 | 0.04f, 0.0f); // previous move target |
743 | 0.04f, 0.0f); // previous move target |
866 | } |
744 | } |
867 | } |
745 | } |
868 | 746 | ||
869 | //////////////////////////////////////////////////////////////////////////////////////////////// |
747 | //////////////////////////////////////////////////////////////////////////////////////////////// |
870 | // now draw the |
748 | // now draw the 3D parts that are still in play |
871 | 749 | ||
- | 750 | // determine display yaw (for flat icons) according to camera angle |
|
- | 751 | if ((current_yaw > 45.0f) && (current_yaw <= 135.0f)) |
|
872 |
|
752 | yaw = 180.0f; |
- | 753 | else if ((current_yaw > -45.0f) && (current_yaw <= 45.0f)) |
|
- | 754 | yaw = 90.0f; |
|
873 | if ( |
755 | else if ((current_yaw > -135.0f) && (current_yaw <= -45.0f)) |
- | 756 | yaw = 0.0f; |
|
- | 757 | else |
|
- | 758 | yaw = -90.0f; |
|
- | 759 | ||
- | 760 | // cycle through all the grid and place all static parts |
|
- | 761 | for (line = 0; line < 8; line++) |
|
874 | { |
762 | { |
875 |
|
763 | for (column = 0; column < 8; column++) |
876 | if ((current_yaw > 45.0f) && (current_yaw <= 135.0f)) |
- | |
877 | yaw = 180.0f; |
- | |
878 | else if ((current_yaw > -45.0f) && (current_yaw <= 45.0f)) |
- | |
879 | yaw = 90.0f; |
- | |
880 | else if ((current_yaw > -135.0f) && (current_yaw <= -45.0f)) |
- | |
881 | yaw = 0.0f; |
- | |
882 |
|
764 | { |
883 |
|
765 | boardslot = ¤tmove->slots[line][column]; // quick access to grid slot |
884 | 766 | ||
- | 767 | // is there nothing on this grid slot ? |
|
- | 768 | if (boardslot->part == PART_NONE) |
|
885 |
|
769 | continue; // then don't draw anything on it |
- | 770 | ||
- | 771 | // is this part not animated ? i.e.: |
|
886 |
|
772 | // has no movement happened yet |
- | 773 | // OR does the movement NOT land on this slot |
|
- | 774 | // AND is it NOT the tower concerned by a castle ? |
|
887 |
|
775 | if ((board->viewed_move == 0) |
- | 776 | || (((line != currentmove->target[0]) || (column != currentmove->target[1])) |
|
- | 777 | && ((towupper (currentmove->pgntext[0]) != L'O') |
|
- | 778 | || (line != (currentmove->color == COLOR_WHITE ? 0 : 7)) || (column != (currentmove->target[1] == 2 ? 3 : 5))))) |
|
888 | { |
779 | { |
889 |
|
780 | // do we want animations AND is it still not time to rotate the board ? |
- | 781 | if (options.want_animations && (animation_endtime + 1.0f > current_time)) |
|
- | 782 | { |
|
- | 783 | // do we want the 3D models or the flat icons ? |
|
- | 784 | // we do when EITHER we don't want flat icons OR the player playing the current move is looking downstraight |
|
- | 785 | if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 786 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 787 | else |
|
- | 788 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
|
- | 789 | } |
|
- | 790 | else |
|
- | 791 | { |
|
- | 792 | // else we are not currently playing an animation - do we want the 3D models or the flat icons ? |
|
- | 793 | // we do when EITHER we don't want flat icons OR the current player is looking downstraight |
|
- | 794 | if (!want_flaticons || (current_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 795 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 796 | else |
|
- | 797 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
|
- | 798 | } |
|
- | 799 | } |
|
- | 800 | } // end for (column = 0; column < 8; column++) |
|
- | 801 | } // end for (line = 0; line < 8; line++) |
|
890 | 802 | ||
891 |
|
803 | // now do another pass and draw the part(s) that are currently moving |
- | 804 | for (line = 0; line < 8; line++) |
|
- | 805 | { |
|
892 |
|
806 | for (column = 0; column < 8; column++) |
- | 807 | { |
|
893 |
|
808 | boardslot = ¤tmove->slots[line][column]; // quick access to grid slot |
894 | 809 | ||
- | 810 | // is there nothing on this grid slot ? |
|
- | 811 | if (boardslot->part == PART_NONE) |
|
- | 812 | continue; // then don't draw anything on it |
|
- | 813 | ||
- | 814 | // has a movement happened yet AND does it land on this slot ? |
|
- | 815 | if ((board->viewed_move > 0) |
|
- | 816 | && (line == currentmove->target[0]) && (column == currentmove->target[1])) |
|
- | 817 | { |
|
895 | // |
818 | // do we want animations AND is it still time to play the animation ? |
- | 819 | if (options.want_animations && (animation_endtime > current_time)) |
|
- | 820 | { |
|
- | 821 | // get the source and target X and Y positions |
|
- | 822 | source_x = 17.5f - (7 - currentmove->source[1]) * 5.0f; |
|
- | 823 | source_y = 17.5f - currentmove->source[0] * 5.0f; |
|
- | 824 | target_x = 17.5f - (7 - currentmove->target[1]) * 5.0f; |
|
- | 825 | target_y = 17.5f - currentmove->target[0] * 5.0f; |
|
- | 826 | ||
- | 827 | // compute the movement completion ratio between 0 and 1 |
|
- | 828 | movement_ratio = 1.0f - (animation_endtime - current_time) / ANIMATION_DURATION; |
|
- | 829 | ||
- | 830 | // compute the current X an Y based on movement timing |
|
- | 831 | current_x = source_x + (target_x - source_x) * movement_ratio; |
|
- | 832 | current_y = source_y + (target_y - source_y) * movement_ratio; |
|
- | 833 | ||
- | 834 | // do we want the 3D models or the flat icons ? |
|
- | 835 | // we do when EITHER we don't want flat icons OR the player playing the current move is looking downstraight |
|
- | 836 | if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 837 | { |
|
- | 838 | // height is a sine positive, max height is proportional to travelled distance |
|
- | 839 | movement_diffco = abs (currentmove->target[1] - currentmove->source[1]); |
|
- | 840 | movement_diffli = abs (currentmove->target[0] - currentmove->source[0]); |
|
- | 841 | movement_maxheight = 0.5f + (float) movement_diffco + (float) movement_diffli; |
|
- | 842 | if (currentmove->part == PART_KNIGHT) |
|
- | 843 | movement_maxheight *= 2.0f; // knights jump high |
|
- | 844 | else if ((currentmove->part == PART_KING) && (movement_diffco == 2)) |
|
- | 845 | movement_maxheight *= 5.0f; // kings jump VERY high when castling too |
|
- | 846 | else if (movement_maxheight > 5.0f) |
|
- | 847 | movement_maxheight = 5.0f; // all other parts just hover above the ground |
|
- | 848 | current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight; |
|
- | 849 | ||
- | 850 | // make this part move realistically |
|
- | 851 | Scene_AddPart (scene, boardslot->part, boardslot->color, current_x, current_y, current_z, 0.0f, (boardslot->color == COLOR_BLACK ? -1 : 1) * min (current_z * 3.0f, 10.0f)); |
|
- | 852 | } |
|
- | 853 | else |
|
- | 854 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.07f, yaw); |
|
- | 855 | } |
|
- | 856 | else |
|
- | 857 | { |
|
- | 858 | // we are not playing an animation, but have we JUST FINISHED playing one ? |
|
- | 859 | if (options.want_animations && (animation_endtime + 1.0f > current_time)) |
|
- | 860 | { |
|
- | 861 | // we've just finished playing an animation - do we want the 3D models or the flat icons ? |
|
- | 862 | // we do when EITHER we don't want flat icons OR the player playing the current move is looking downstraight |
|
- | 863 | if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 864 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 865 | else |
|
- | 866 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
|
- | 867 | } |
|
- | 868 | else |
|
- | 869 | { |
|
- | 870 | // else we are not currently playing an animation - do we want the 3D models or the flat icons ? |
|
- | 871 | // we do when EITHER we don't want flat icons OR the current player is looking downstraight |
|
- | 872 | if (!want_flaticons || (current_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 873 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 874 | else |
|
896 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
875 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
- | 876 | } |
|
- | 877 | } |
|
- | 878 | ||
- | 879 | // is it time to play a move sound ? |
|
- | 880 | if ((sound_playtime != 0) && (sound_playtime < current_time)) |
|
- | 881 | { |
|
- | 882 | // is the current player in check ? (to play the right sound) |
|
- | 883 | // read as: was the last move an opponent's move AND did it put us to check ? |
|
- | 884 | if (currentmove->is_check) |
|
- | 885 | { |
|
- | 886 | // is it a checkmate or a normal check ? (checkmate == check + stalemate) |
|
- | 887 | if (currentmove->is_stalemate) |
|
- | 888 | Audio_PlaySound (board->players[currentmove->color].type == PLAYER_HUMAN ? SOUNDTYPE_VICTORY : SOUNDTYPE_DEFEAT); // if so, play endgame sound |
|
- | 889 | else |
|
- | 890 | Audio_PlaySound (SOUNDTYPE_CHECK); // else play the check sound |
|
- | 891 | } |
|
- | 892 | else |
|
- | 893 | { |
|
- | 894 | // is it a stalemate, a capture or a normal move ? |
|
- | 895 | if (currentmove->is_stalemate) |
|
- | 896 | Audio_PlaySound (SOUNDTYPE_DEFEAT); // on stalemate, play defeat sound |
|
- | 897 | else if (currentmove->has_captured) |
|
- | 898 | Audio_PlaySound (SOUNDTYPE_PIECETAKEN); // on capture, play the capture sound |
|
- | 899 | else |
|
- | 900 | Audio_PlaySound (SOUNDTYPE_MOVE); // else play the normal move sound |
|
- | 901 | } |
|
- | 902 | ||
- | 903 | sound_playtime = 0; // mark this animation as completed and sound played |
|
- | 904 | } |
|
897 | } |
905 | } |
- | 906 | ||
- | 907 | // else has a movement happened yet AND is this movement a castle AND is this the concerned tower ? |
|
- | 908 | else if ((board->viewed_move > 0) |
|
- | 909 | && (towupper (currentmove->pgntext[0]) == L'O') // either O-O-O or O-O |
|
- | 910 | && (line == (currentmove->color == COLOR_WHITE ? 0 : 7)) && (column == (currentmove->target[1] == 2 ? 3 : 5))) |
|
- | 911 | { |
|
- | 912 | // do we want animations AND is it still time to play the animation ? (castling rooks move faster) |
|
- | 913 | if (options.want_animations && (animation_endtime - (0.5f * ANIMATION_DURATION) > current_time)) |
|
- | 914 | { |
|
- | 915 | // get the source and target X and Y positions |
|
- | 916 | source_x = 17.5f - (7 - (currentmove->target[1] == 2 ? 0 : 7)) * 5.0f; // if king moves left, then rook starts on column a, else it starts on column h |
|
- | 917 | source_y = 17.5f - line * 5.0f; |
|
- | 918 | target_x = 17.5f - (7 - column) * 5.0f; |
|
- | 919 | target_y = 17.5f - line * 5.0f; |
|
- | 920 | ||
- | 921 | // compute the movement completion ratio between 0 and 1 (castling rooks move faster) |
|
- | 922 | movement_ratio = min (1.0f, 1.0f - (animation_endtime - (0.5f * ANIMATION_DURATION) - current_time) / (0.5f * ANIMATION_DURATION)); |
|
- | 923 | ||
- | 924 | // compute the current X an Y based on movement timing |
|
- | 925 | current_x = source_x + (target_x - source_x) * movement_ratio; |
|
- | 926 | current_y = source_y + (target_y - source_y) * movement_ratio; |
|
- | 927 | ||
- | 928 | // height is a sine positive, max height is proportional to travelled distance |
|
- | 929 | movement_maxheight = 1.0f; // castling rook will barely hover above the ground |
|
- | 930 | current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight; |
|
- | 931 | ||
- | 932 | // make this part move realistically - do we want the 3D models or the flat icons ? |
|
- | 933 | // we do when EITHER we don't want flat icons OR the player playing the current move is looking downstraight |
|
- | 934 | if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 935 | Scene_AddPart (scene, boardslot->part, boardslot->color, current_x, current_y, current_z, 0.0f, (boardslot->color == COLOR_BLACK ? -1 : 1) * min (current_z * 3.0f, 10.0f)); |
|
- | 936 | else |
|
- | 937 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.09f, yaw); |
|
- | 938 | ||
- | 939 | if (movement_ratio < 0.9f) |
|
- | 940 | rooksound_played = false; // if the rook is still moving, reset the "sound played" flag |
|
- | 941 | else if (!rooksound_played) |
|
- | 942 | { |
|
- | 943 | Audio_PlaySound (SOUNDTYPE_MOVE); // when the rook has landed, play a move sound |
|
- | 944 | rooksound_played = true; // remember this is no longer to be done |
|
- | 945 | } |
|
- | 946 | } |
|
- | 947 | else |
|
- | 948 | { |
|
- | 949 | // do we want animations AND is it still not time to rotate the board ? |
|
- | 950 | if (options.want_animations && (animation_endtime + 1.0f > current_time)) |
|
- | 951 | { |
|
- | 952 | // do we want the 3D models or the flat icons ? |
|
- | 953 | // we do when EITHER we don't want flat icons OR the player playing the current move is looking downstraight |
|
- | 954 | if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 955 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 956 | else |
|
- | 957 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
|
- | 958 | } |
|
- | 959 | else |
|
- | 960 | { |
|
- | 961 | // else we are not currently playing an animation - do we want the 3D models or the flat icons ? |
|
- | 962 | // we do when EITHER we don't want flat icons OR the current player is looking downstraight |
|
- | 963 | if (!want_flaticons || (current_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS)) |
|
- | 964 | Scene_AddPart (scene, boardslot->part, boardslot->color, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.04f, 0.0f, 0.0f); |
|
- | 965 | else |
|
- | 966 | Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, yaw); |
|
- | 967 | } |
|
- | 968 | } |
|
898 | } |
969 | } |
- | 970 | } // end for (column = 0; column < 8; column++) |
|
- | 971 | } // end for (line = 0; line < 8; line++) |
|
899 | 972 | ||
900 | /////////////////////////////////////////////////////////// |
973 | /////////////////////////////////////////////////////////// |
901 | // now draw the sepia overlay if we're in history view mode |
974 | // now draw the sepia overlay if we're in history view mode |
902 | 975 | ||
903 | if (options.want_sepiafilter && (board->move_count > 1) && (board->viewed_move != board->move_count - 1)) |
976 | if (options.want_sepiafilter && (board->move_count > 1) && (board->viewed_move != board->move_count - 1)) |