gnome-games r8162 - trunk/aisleriot



Author: jclinton
Date: Tue Oct 21 19:47:08 2008
New Revision: 8162
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8162&view=rev

Log:
Added a function to calculate the pixel position of a card within a
slot.

Modified:
   trunk/aisleriot/game.c
   trunk/aisleriot/game.h

Modified: trunk/aisleriot/game.c
==============================================================================
--- trunk/aisleriot/game.c	(original)
+++ trunk/aisleriot/game.c	Tue Oct 21 19:47:08 2008
@@ -2067,3 +2067,29 @@
   aisleriot_game_end_move (game);
   aisleriot_game_test_end_of_game (game);
 }
+
+void
+aisleriot_game_get_card_offset (Slot *slot,
+                                guint card_num,
+                                gboolean old_cards,
+                                gint *xoff, gint *yoff)
+{
+  gint n_cards, exposed;
+
+  if (old_cards) {
+    n_cards = (gint) slot->old_cards->len;
+    exposed = (gint) slot->old_exposed;
+  } else {
+    n_cards = (gint) slot->cards->len;
+    exposed = (gint) slot->exposed;
+  }
+
+  if (card_num >= n_cards - exposed) {
+    gint index = card_num + exposed - n_cards;
+    *xoff = slot->pixeldx * index;
+    *yoff = slot->pixeldy * index;
+  } else {
+    *xoff = 0;
+    *yoff = 0;
+  }
+}

Modified: trunk/aisleriot/game.h
==============================================================================
--- trunk/aisleriot/game.h	(original)
+++ trunk/aisleriot/game.h	Tue Oct 21 19:47:08 2008
@@ -35,6 +35,7 @@
 
   GByteArray *cards;
   /* The old state of the cards so we can check for differences */
+  guint old_exposed;
   GByteArray *old_cards;
 
   /* the topmost |exposed| cards are shown on the pile */
@@ -192,6 +193,11 @@
 
 void aisleriot_game_deal_cards (AisleriotGame *game);
 
+void aisleriot_game_get_card_offset (Slot *slot,
+                                     guint card_num,
+                                     gboolean old_cards,
+                                     gint *xoff, gint *yoff);
+
 G_END_DECLS
 
 #endif /* !AISLERIOT_GAME_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]