Subversion Repositories Games.Chess Giants

Rev

Rev 24 | Rev 75 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24 Rev 25
Line 144... Line 144...
144
   int length;
144
   int length;
145
   int threat_line;
145
   int threat_line;
146
   int threat_column;
146
   int threat_column;
147
   int minutes;
147
   int minutes;
148
   int seconds;
148
   int seconds;
149
   float yaw;
149
   float flaticons_yaw;
150
   float source_x;
150
   float source_x;
151
   float source_y;
151
   float source_y;
152
   float target_x;
152
   float target_x;
153
   float target_y;
153
   float target_y;
154
   float current_x;
154
   float current_x;
Line 161... Line 161...
161
 
161
 
162
   // get the current player (we'll need it), its opponent and see if we're online
162
   // get the current player (we'll need it), its opponent and see if we're online
163
   current_player = Player_GetCurrent ();
163
   current_player = Player_GetCurrent ();
164
   opposite_player = Player_GetOpposite ();
164
   opposite_player = Player_GetOpposite ();
165
   network_player = Player_FindByType (PLAYER_INTERNET);
165
   network_player = Player_FindByType (PLAYER_INTERNET);
-
 
166
 
-
 
167
   // determine display yaw (for flat icons) according to camera angle
-
 
168
   if ((current_yaw > 45.0f) && (current_yaw <= 135.0f))
-
 
169
      flaticons_yaw = 180.0f;
-
 
170
   else if ((current_yaw > -45.0f) && (current_yaw <= 45.0f))
-
 
171
      flaticons_yaw = 90.0f;
-
 
172
   else if ((current_yaw > -135.0f) && (current_yaw <= -45.0f))
-
 
173
      flaticons_yaw = 0.0f;
-
 
174
   else
-
 
175
      flaticons_yaw = -90.0f;
166
 
176
 
167
   // get the current move
177
   // get the current move
168
   currentmove = &board->moves[board->viewed_move]; // quick access to current move
178
   currentmove = &board->moves[board->viewed_move]; // quick access to current move
169
 
179
 
170
   // fetch the background sprite from the theme
180
   // fetch the background sprite from the theme
Line 668... Line 678...
668
            }
678
            }
669
         }
679
         }
670
   } // end if (play mode)
680
   } // end if (play mode)
671
 
681
 
672
   ////////////////////////////////////////////////////////////////////////////////////////////////
682
   ////////////////////////////////////////////////////////////////////////////////////////////////
673
   // and finally place the parts that are off-board (taken parts)
683
   // now place the parts that are off-board (taken parts)
674
 
684
 
675
   // but only if we want them displayed
685
   // but only if we want them displayed
676
   if (options.want_takenparts)
686
   if (options.want_takenparts)
677
   {
687
   {
678
      // draw the white player's taken parts, place the part off the board (watch out for the hack...)
688
      // draw the white player's taken parts, place the part off the board (watch out for the hack...)
679
      for (part_index = 0; part_index < currentmove->sides[COLOR_WHITE].takenpart_count; part_index++)
689
      for (part_index = 0; part_index < currentmove->sides[COLOR_WHITE].takenpart_count; part_index++)
680
      {
690
      {
681
         takenpart_type = currentmove->sides[COLOR_WHITE].takenparts[part_index];
691
         takenpart_type = currentmove->sides[COLOR_WHITE].takenparts[part_index];
-
 
692
 
-
 
693
         // do we want the 3D models or the flat icons ?
-
 
694
         // we do when EITHER we don't want flat icons OR the current player is looking downstraight
-
 
695
         if (!want_flaticons || (current_pitch < MAX_PITCH_FOR_FLAT_ICONS))
682
         Scene_AddPart (scene, takenpart_type, COLOR_BLACK, (part_index < MAX_STACKABLE_PARTS ? 23.2f : 26.8f),
696
            Scene_AddPart (scene, takenpart_type, COLOR_BLACK, (part_index < MAX_STACKABLE_PARTS ? 23.2f : 26.8f),
683
                        (part_index % MAX_STACKABLE_PARTS == 0 ? 23.2f : scene->objects[scene->object_count - 1].y - (scene->objects[scene->object_count - 1].simpleshadow_size + simpleshadow_sizes[takenpart_type]) * 0.75f),
697
                           (part_index % MAX_STACKABLE_PARTS == 0 ? 23.2f : scene->objects[scene->object_count - 1].y - (scene->objects[scene->object_count - 1].simpleshadow_size + simpleshadow_sizes[takenpart_type]) * 0.75f),
684
                        0.04f, (takenpart_type == PART_PAWN ? -90.0f : 100.0f), 0.0f); // rotate pawns 90°
698
                           0.04f, (takenpart_type == PART_PAWN ? -90.0f : 100.0f), 0.0f); // rotate pawns 90°
-
 
699
         else
-
 
700
            Scene_AddTile (scene, theme->flattextures[COLOR_BLACK][takenpart_type], 1.25f, (part_index < MAX_STACKABLE_PARTS ? 23.2f : 26.8f),
-
 
701
                           20.0f - (part_index < MAX_STACKABLE_PARTS ? part_index : (part_index - MAX_STACKABLE_PARTS)) * 2.5f, 0.07f, flaticons_yaw);
685
      }
702
      }
686
 
703
 
687
      // now draw the black player's taken parts, place the part off the board (watch out for the hack...)
704
      // now draw the black player's taken parts, place the part off the board (watch out for the hack...)
688
      for (part_index = 0; part_index < currentmove->sides[COLOR_BLACK].takenpart_count; part_index++)
705
      for (part_index = 0; part_index < currentmove->sides[COLOR_BLACK].takenpart_count; part_index++)
689
      {
706
      {
690
         takenpart_type = currentmove->sides[COLOR_BLACK].takenparts[part_index];
707
         takenpart_type = currentmove->sides[COLOR_BLACK].takenparts[part_index];
-
 
708
 
-
 
709
         // do we want the 3D models or the flat icons ?
-
 
710
         // we do when EITHER we don't want flat icons OR the current player is looking downstraight
-
 
711
         if (!want_flaticons || (current_pitch < MAX_PITCH_FOR_FLAT_ICONS))
691
         Scene_AddPart (scene, takenpart_type, COLOR_WHITE, (part_index < MAX_STACKABLE_PARTS ? -23.2f : -26.8f),
712
            Scene_AddPart (scene, takenpart_type, COLOR_WHITE, (part_index < MAX_STACKABLE_PARTS ? -23.2f : -26.8f),
692
                        (part_index % MAX_STACKABLE_PARTS == 0 ? -23.2f : scene->objects[scene->object_count - 1].y + (scene->objects[scene->object_count - 1].simpleshadow_size + simpleshadow_sizes[takenpart_type]) * 0.75f),
713
                           (part_index % MAX_STACKABLE_PARTS == 0 ? -23.2f : scene->objects[scene->object_count - 1].y + (scene->objects[scene->object_count - 1].simpleshadow_size + simpleshadow_sizes[takenpart_type]) * 0.75f),
693
                        0.04f, (takenpart_type == PART_PAWN ? -90.0f : 100.0f), 0.0f); // rotate pawns 90°
714
                           0.04f, (takenpart_type == PART_PAWN ? -90.0f : 100.0f), 0.0f); // rotate pawns 90°
-
 
715
         else
-
 
716
            Scene_AddTile (scene, theme->flattextures[COLOR_WHITE][takenpart_type], 1.25f, (part_index < MAX_STACKABLE_PARTS ? -23.2f : -26.8f),
-
 
717
                           -20.0f + (part_index < MAX_STACKABLE_PARTS ? part_index : (part_index - MAX_STACKABLE_PARTS)) * 2.5f, 0.07f, flaticons_yaw);
694
      }
718
      }
695
   }
719
   }
696
 
720
 
697
   ////////////////////////////////////////////////////////////////////////////////////////////////
721
   ////////////////////////////////////////////////////////////////////////////////////////////////
698
   // now draw the textured slots
722
   // now draw the textured slots
Line 744... Line 768...
744
      }
768
      }
745
   }
769
   }
746
 
770
 
747
   ////////////////////////////////////////////////////////////////////////////////////////////////
771
   ////////////////////////////////////////////////////////////////////////////////////////////////
748
   // now draw the 3D parts that are still in play
772
   // now draw the 3D parts that are still in play
749
 
-
 
750
   // determine display yaw (for flat icons) according to camera angle
-
 
751
   if ((current_yaw > 45.0f) && (current_yaw <= 135.0f))
-
 
752
      yaw = 180.0f;
-
 
753
   else if ((current_yaw > -45.0f) && (current_yaw <= 45.0f))
-
 
754
      yaw = 90.0f;
-
 
755
   else if ((current_yaw > -135.0f) && (current_yaw <= -45.0f))
-
 
756
      yaw = 0.0f;
-
 
757
   else
-
 
758
      yaw = -90.0f;
-
 
759
 
773
 
760
   // cycle through all the grid and place all static parts
774
   // cycle through all the grid and place all static parts
761
   for (line = 0; line < 8; line++)
775
   for (line = 0; line < 8; line++)
762
   {
776
   {
763
      for (column = 0; column < 8; column++)
777
      for (column = 0; column < 8; column++)
Line 775... Line 789...
775
         if ((board->viewed_move == 0)
789
         if ((board->viewed_move == 0)
776
             || (((line != currentmove->target[0]) || (column != currentmove->target[1]))
790
             || (((line != currentmove->target[0]) || (column != currentmove->target[1]))
777
                 && ((towupper (currentmove->pgntext[0]) != L'O')
791
                 && ((towupper (currentmove->pgntext[0]) != L'O')
778
                     || (line != (currentmove->color == COLOR_WHITE ? 0 : 7)) || (column != (currentmove->target[1] == 2 ? 3 : 5)))))
792
                     || (line != (currentmove->color == COLOR_WHITE ? 0 : 7)) || (column != (currentmove->target[1] == 2 ? 3 : 5)))))
779
         {
793
         {
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 ?
794
            // 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
795
            // 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))
796
            if (!want_flaticons || (current_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);
797
               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
798
            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);
799
               Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, flaticons_yaw);
798
            }
-
 
799
         }
800
         }
800
      } // end for (column = 0; column < 8; column++)
801
      } // end for (column = 0; column < 8; column++)
801
   } // end for (line = 0; line < 8; line++)
802
   } // end for (line = 0; line < 8; line++)
802
 
803
 
803
   // now do another pass and draw the part(s) that are currently moving
804
   // now do another pass and draw the part(s) that are currently moving
Line 831... Line 832...
831
               current_x = source_x + (target_x - source_x) * movement_ratio;
832
               current_x = source_x + (target_x - source_x) * movement_ratio;
832
               current_y = source_y + (target_y - source_y) * movement_ratio;
833
               current_y = source_y + (target_y - source_y) * movement_ratio;
833
 
834
 
834
               // do we want the 3D models or the flat icons ?
835
               // 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
               // 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
               if (!want_flaticons || (current_pitch < MAX_PITCH_FOR_FLAT_ICONS))
837
               {
838
               {
838
                  // height is a sine positive, max height is proportional to travelled distance
839
                  // height is a sine positive, max height is proportional to travelled distance
839
                  movement_diffco = abs (currentmove->target[1] - currentmove->source[1]);
840
                  movement_diffco = abs (currentmove->target[1] - currentmove->source[1]);
840
                  movement_diffli = abs (currentmove->target[0] - currentmove->source[0]);
841
                  movement_diffli = abs (currentmove->target[0] - currentmove->source[0]);
841
                  movement_maxheight = 0.5f + (float) movement_diffco + (float) movement_diffli;
842
                  movement_maxheight = 0.5f + (float) movement_diffco + (float) movement_diffli;
Line 849... Line 850...
849
 
850
 
850
                  // make this part move realistically
851
                  // 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
                  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
               }
853
               else
854
               else
854
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.07f, yaw);
855
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.07f, flaticons_yaw);
855
            }
856
            }
856
            else
857
            else
857
            {
858
            {
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 ?
859
               // 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
860
               // we do when EITHER we don't want flat icons OR the current player is looking downstraight
863
                  if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS))
861
               if (!want_flaticons || (current_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);
862
                  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
863
               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
-
 
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);
864
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, flaticons_yaw);
876
               }
-
 
877
            }
865
            }
878
 
866
 
879
            // is it time to play a move sound ?
867
            // is it time to play a move sound ?
880
            if ((sound_playtime != 0) && (sound_playtime < current_time))
868
            if ((sound_playtime != 0) && (sound_playtime < current_time))
881
            {
869
            {
Line 929... Line 917...
929
               movement_maxheight = 1.0f; // castling rook will barely hover above the ground
917
               movement_maxheight = 1.0f; // castling rook will barely hover above the ground
930
               current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight;
918
               current_z = 0.04f + sin (MATH_PI * movement_ratio) * movement_maxheight;
931
 
919
 
932
               // make this part move realistically - do we want the 3D models or the flat icons ?
920
               // 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
921
               // 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))
922
               if (!want_flaticons || (current_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));
923
                  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
924
               else
937
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.09f, yaw);
925
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, current_x, current_y, 0.09f, flaticons_yaw);
938
 
926
 
939
               if (movement_ratio < 0.9f)
927
               if (movement_ratio < 0.9f)
940
                  rooksound_played = false; // if the rook is still moving, reset the "sound played" flag
928
                  rooksound_played = false; // if the rook is still moving, reset the "sound played" flag
941
               else if (!rooksound_played)
929
               else if (!rooksound_played)
942
               {
930
               {
Line 944... Line 932...
944
                  rooksound_played = true; // remember this is no longer to be done
932
                  rooksound_played = true; // remember this is no longer to be done
945
               }
933
               }
946
            }
934
            }
947
            else
935
            else
948
            {
936
            {
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 ?
937
               // 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
938
               // we do when EITHER we don't want flat icons OR the current player is looking downstraight
954
                  if (!want_flaticons || (opposite_player->view_pitch < MAX_PITCH_FOR_FLAT_ICONS))
939
               if (!want_flaticons || (current_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);
940
                  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
941
               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);
942
                  Scene_AddTile (scene, theme->flattextures[boardslot->color][boardslot->part], 2.5f, 17.5f - (7 - column) * 5.0f, 17.5f - line * 5.0f, 0.05f, flaticons_yaw);
967
               }
-
 
968
            }
943
            }
969
         }
944
         }
970
      } // end for (column = 0; column < 8; column++)
945
      } // end for (column = 0; column < 8; column++)
971
   } // end for (line = 0; line < 8; line++)
946
   } // end for (line = 0; line < 8; line++)
972
 
947