]> hydra-www.ietfng.org Git - gtetrinet/commitdiff
Stanislav Lechev's shadow-block patch
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 29 Jan 2016 06:52:24 +0000 (01:52 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 29 Jan 2016 06:56:38 +0000 (01:56 -0500)
Originally from http://0xaf.org/software/gtetrinet-0.7.11-shadow.patch

src/fields.c
src/fields.h
src/tetris.c

index e0ba2f747eb7adaf1e449b552a871e9c13032d38..2af530141ec2543a52a5a85bc37841cdd214d243 100644 (file)
@@ -48,7 +48,7 @@ static gint fields_nextpiece_expose (GtkWidget *widget);
 static gint fields_specials_expose (GtkWidget *widget);
 
 static void fields_refreshfield (int field);
-static void fields_drawblock (int field, int x, int y, char block);
+void fields_drawblock (int field, int x, int y, char block);
 
 static void gmsginput_activate (void);
 
@@ -361,10 +361,8 @@ void fields_drawfield (int field, FIELD newfield)
     int x, y;
     for (y = 0; y < FIELDHEIGHT; y ++)
         for (x = 0; x < FIELDWIDTH; x ++)
-            if (newfield[y][x] != displayfields[field][y][x]) {
                 fields_drawblock (field, x, y, newfield[y][x]);
                 displayfields[field][y][x] = newfield[y][x];
-            }
 }
 
 void fields_drawblock (int field, int x, int y, char block)
index b565656e07c82486ae2165efdbb6bce2eb0aad8f..f3c442c6d3f9a1446f9a1bc09e6ad4911fa479f2 100644 (file)
@@ -22,3 +22,7 @@ extern void fields_gmsginput (int i);
 extern void fields_gmsginputclear (void);
 extern void fields_gmsginputactivate (int i);
 extern const char *fields_gmsginputtext (void);
+
+
+//AF
+extern void fields_drawblock (int field, int x, int y, char block);
index 04be999898b4742e49252f833b386b7f5d0b0b57..faff6318652290ade932a38029092b810ba049dc 100644 (file)
@@ -165,6 +165,32 @@ void tetris_drawcurrentblock (void)
     if (blocknum >= 0)
         placeblock (field, blocknum, blockorient, blockx, blocky);
     fields_drawfield (playerfield(playernum), field);
+
+
+    // AF: make shadow
+    FIELD shadowfield;
+    int x, y, y1, f;
+
+    if (blocknum < 0) return;
+
+    y1=0;
+    while (!blockobstructed(fields[playernum], blocknum, blockorient, blockx, y1))
+           y1++;
+    y1--;
+
+    if (y1-4<=blocky) return;
+
+    copyfield (shadowfield, field);
+    if (blocknum >= 0)
+        placeblock (shadowfield, blocknum, blockorient, blockx, y1);
+    f = playerfield(playernum);
+
+    for (y = 0; y < FIELDHEIGHT; y ++)
+        for (x = 0; x < FIELDWIDTH; x ++)
+            if (shadowfield[y][x] != fields[playernum][y][x]) {
+                fields_drawblock (f, x, y, shadowfield[y][x]);
+            }
+
 }
 
 int tetris_makeblock (int block, int orient)