gnome-games r8683 - trunk/gnometris
- From: jclinton svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8683 - trunk/gnometris
- Date: Sun, 8 Feb 2009 06:34:21 +0000 (UTC)
Author: jclinton
Date: Sun Feb 8 06:34:21 2009
New Revision: 8683
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8683&view=rev
Log:
This completes the line deleting animation rewrite.
The order of scanning the field was changed from top-to-bottom to
bottom-to-top. I'm not 100% sure about the field boundary arithmetic but
after playing it for 30 minutes, I didn't witness any problems.
Modified:
trunk/gnometris/blockops.cpp
trunk/gnometris/blockops.h
Modified: trunk/gnometris/blockops.cpp
==============================================================================
--- trunk/gnometris/blockops.cpp (original)
+++ trunk/gnometris/blockops.cpp Sun Feb 8 06:34:21 2009
@@ -26,7 +26,6 @@
#define FONT "Sans Bold"
-//FIXME ... g_list_free somewhere during Tetris dtor?
GList *Block::destroy_actors = NULL;
void
@@ -272,47 +271,56 @@
void
BlockOps::eliminateLine(int l)
{
- for (int y = l; y > 0; --y)
+ for (int x = 0; x < COLUMNS; ++x)
{
- for (int x = 0; x < COLUMNS; ++x)
+ if (field[x][l].actor) {
+ clutter_effect_fade (tmpl, field[x][l].actor, 0, NULL, NULL);
+ Block::destroy_actors = g_list_append (Block::destroy_actors,
+ field[x][l].actor);
+ }
+ }
+}
+
+bool
+BlockOps::checkFullLine(int l)
+{
+ bool f = true;
+ for (int x = 0; x < COLUMNS; ++x)
+ {
+ if (field[x][l].what != LAYING)
{
- field[x][y].move_from (field[x][y - 1]);
+ f = false;
+ break;
}
}
+
+ return f;
}
int
BlockOps::checkFullLines()
{
// we can have at most 4 full lines (vertical block)
- int fullLines[4] = {0, };
int numFullLines = 0;
- for (int y = posy; y < MIN(posy + 4, LINES); ++y)
+ for (int y = MIN (posy + 4, LINES); y > 0; --y)
{
- bool f = true;
- for (int x = 0; x < COLUMNS; ++x)
+ if (checkFullLine (y))
{
- if (field[x][y].what != LAYING)
- {
- f = false;
- break;
- }
+ ++numFullLines;
+ eliminateLine(y);
}
-
- if (f)
+ else if (numFullLines > 0)
{
- fullLines[numFullLines] = y;
- ++numFullLines;
+ for (int x = 0; x < COLUMNS; ++x)
+ {
+ field[x][y+numFullLines].move_from (field[x][y]);
+ }
}
}
if (numFullLines > 0)
{
- for (int i = 0; i < numFullLines; ++i)
- {
- eliminateLine(fullLines[i]);
- }
g_signal_connect (timeline, "completed",
G_CALLBACK (Block::animation_destroy), (gpointer) NULL);
clutter_timeline_start (timeline);
Modified: trunk/gnometris/blockops.h
==============================================================================
--- trunk/gnometris/blockops.h (original)
+++ trunk/gnometris/blockops.h Sun Feb 8 06:34:21 2009
@@ -96,6 +96,7 @@
SlotType fill);
bool blockOkHere (int x, int y, int b, int r);
void eliminateLine (int l);
+ bool checkFullLine(int l);
GtkWidget * w;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]