gnome-games r8163 - trunk/aisleriot
- From: jclinton svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8163 - trunk/aisleriot
- Date: Tue, 21 Oct 2008 19:47:15 +0000 (UTC)
Author: jclinton
Date: Tue Oct 21 19:47:14 2008
New Revision: 8163
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8163&view=rev
Log:
Fixed positioning of animated cards. It now no longer duplicates
drawing cards that are animated.
Modified:
trunk/aisleriot/board.c
trunk/aisleriot/slot-renderer.c
Modified: trunk/aisleriot/board.c
==============================================================================
--- trunk/aisleriot/board.c (original)
+++ trunk/aisleriot/board.c Tue Oct 21 19:47:14 2008
@@ -857,8 +857,12 @@
RemovedCard removed_card;
removed_card.card = CARD (slot->old_cards->data[i]);
- removed_card.cardx = slot->rect.x + slot->pixeldx * i;
- removed_card.cardy = slot->rect.y + slot->pixeldy * i;
+ aisleriot_game_get_card_offset (slot, i,
+ TRUE,
+ &removed_card.cardx,
+ &removed_card.cardy);
+ removed_card.cardx += slot->rect.x;
+ removed_card.cardy += slot->rect.y;
g_array_append_val (removed_cards, removed_card);
}
}
@@ -883,8 +887,10 @@
&& old_card.attr.face_down != new_card.attr.face_down) {
AisleriotAnimStart anim;
- anim.cardx = slot->pixeldx * (slot->cards->len - 1);
- anim.cardy = slot->pixeldy * (slot->cards->len - 1);
+ aisleriot_game_get_card_offset (slot, slot->cards->len - 1,
+ FALSE,
+ &anim.cardx,
+ &anim.cardy);
anim.face_down = old_card.attr.face_down;
g_array_append_val (animations, anim);
@@ -908,8 +914,8 @@
&& added_card.attr.rank == removed_card->card.attr.rank) {
AisleriotAnimStart anim;
- anim.cardx = removed_card->cardx - slot->rect.x + slot->pixeldx * i;
- anim.cardy = removed_card->cardy - slot->rect.y + slot->pixeldy * i;
+ anim.cardx = removed_card->cardx - slot->rect.x;
+ anim.cardy = removed_card->cardy - slot->rect.y;
anim.face_down = removed_card->card.attr.face_down;
g_array_append_val (animations, anim);
@@ -929,6 +935,7 @@
/* Set the old cards back to the new cards */
g_byte_array_set_size (slot->old_cards, 0);
g_byte_array_append (slot->old_cards, slot->cards->data, slot->cards->len);
+ slot->old_exposed = slot->exposed;
}
g_array_free (animations, TRUE);
Modified: trunk/aisleriot/slot-renderer.c
==============================================================================
--- trunk/aisleriot/slot-renderer.c (original)
+++ trunk/aisleriot/slot-renderer.c Tue Oct 21 19:47:14 2008
@@ -267,9 +267,10 @@
{
AisleriotSlotRenderer *srend = (AisleriotSlotRenderer *) actor;
AisleriotSlotRendererPrivate *priv = srend->priv;
- guint n_cards, first_exposed_card_id, i;
+ guint n_cards;
guint8 *cards;
int cardx, cardy;
+ guint i;
g_return_if_fail (priv->cache != NULL);
g_return_if_fail (priv->slot != NULL);
@@ -278,9 +279,9 @@
n_cards = priv->slot->cards->len;
g_assert (n_cards >= priv->slot->exposed);
- first_exposed_card_id = n_cards - priv->slot->exposed;
+ g_assert (n_cards >= priv->animations->len);
- if (priv->slot->cards->len == 0) {
+ if (priv->slot->cards->len <= priv->animations->len) {
CoglHandle cogl_tex;
guint tex_width, tex_height;
@@ -296,33 +297,39 @@
0, 0, CFX_ONE, CFX_ONE);
}
- cardx = 0;
- cardy = 0;
-
- for (i = first_exposed_card_id; i < n_cards; ++i) {
- Card card = CARD (cards[i]);
- gboolean is_highlighted;
- CoglHandle cogl_tex;
- guint tex_width, tex_height;
+ if (n_cards > priv->animations->len) {
+ guint first_card, last_card;
- is_highlighted = priv->show_highlight && (i >= priv->highlight_start);
-
- cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache,
- card,
- is_highlighted);
-
- tex_width = cogl_texture_get_width (cogl_tex);
- tex_height = cogl_texture_get_height (cogl_tex);
-
- cogl_texture_rectangle (cogl_tex,
- CLUTTER_INT_TO_FIXED (cardx),
- CLUTTER_INT_TO_FIXED (cardy),
- CLUTTER_INT_TO_FIXED (cardx + tex_width),
- CLUTTER_INT_TO_FIXED (cardy + tex_height),
- 0, 0, CFX_ONE, CFX_ONE);
-
- cardx += priv->slot->pixeldx;
- cardy += priv->slot->pixeldy;
+ first_card = MIN (n_cards - priv->animations->len - 1,
+ n_cards - priv->slot->exposed);
+ last_card = n_cards - priv->animations->len;
+
+ for (i = first_card; i < last_card; i++) {
+ Card card = CARD (cards[i]);
+ gboolean is_highlighted;
+ CoglHandle cogl_tex;
+ guint tex_width, tex_height;
+
+ is_highlighted = priv->show_highlight && (i >= priv->highlight_start);
+
+ cogl_tex = aisleriot_card_cache_get_card_texture (priv->cache,
+ card,
+ is_highlighted);
+
+ tex_width = cogl_texture_get_width (cogl_tex);
+ tex_height = cogl_texture_get_height (cogl_tex);
+
+ aisleriot_game_get_card_offset (priv->slot, i,
+ FALSE,
+ &cardx, &cardy);
+
+ cogl_texture_rectangle (cogl_tex,
+ CLUTTER_INT_TO_FIXED (cardx),
+ CLUTTER_INT_TO_FIXED (cardy),
+ CLUTTER_INT_TO_FIXED (cardx + tex_width),
+ CLUTTER_INT_TO_FIXED (cardy + tex_height),
+ 0, 0, CFX_ONE, CFX_ONE);
+ }
}
/* Paint the animated actors */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]